1 <?php # vim:ts=2:sw=2:et:
2 /* For licensing and copyright terms, see the file named LICENSE */
4 include '../inc/common.php';
6 MTrackACL::requireAllRights('Browser', 'read');
8 $path = mtrack_get_pathinfo(true);
10 $repo = MTrackSCM::factory($pi);
12 MTrackACL::requireAllRights("repo:$repo->repoid", 'read');
14 function get_change_data($pi)
16 $repo = MTrackSCM::factory($pi);
17 $ents = $repo->history(null, 1, 'rev', $pi);
25 // Determine project from the file list
26 $the_proj = $repo->projectFromPath($ent->files);
28 $proj = MTrackProject::loadById($the_proj);
29 $changelog = $proj->adjust_links($ent->changelog, true);
31 $changelog = $ent->changelog;
33 $data->changelog = $changelog;
35 if (is_array($ent->files)) foreach ($ent->files as $file) {
36 $file->diff = mtrack_diff($repo->diff($file, $ent->rev));
43 function get_change_data_relatives($pi, $rev)
45 $repo = MTrackSCM::factory($pi);
47 list($data->parents, $data->kids) = $repo->getRelatedChanges($rev);
51 $data = mtrack_cache('get_change_data', array($path), 864000);
54 throw new Exception("invalid parameters");
57 $rdata = mtrack_cache('get_change_data_relatives', array($path, $ent->rev));
59 if (isset($_GET['fmt']) && $_GET['fmt'] == 'diff') {
60 $filename = "$repo->shortname.$ent->rev.diff";
61 header("Content-Type: text/plain; name=\"$filename\"");
62 header("Content-Disposition: attachment; filename=\"$filename\"");
64 echo "Changeset: $repo->shortname $ent->rev\n";
65 echo "By: $ent->changeby\n";
66 echo "When: $ent->ctime\n";
68 echo $data->changelog . "\n\n";
70 if (is_array($ent->files) && count($ent->files)) {
71 foreach ($ent->files as $id => $file) {
72 echo "$file->status $file->name\n";
76 foreach ($ent->files as $id => $file) {
78 if ($fpath[0] != '/') $fpath = '/' . $fpath;
79 $diff = $repo->diff($file, $ent->rev);
80 if (is_resource($diff)) {
81 echo stream_get_contents($diff);
82 } elseif (is_array($diff)) {
83 echo join("\n", $diff);
92 mtrack_head("Changeset " . $ent->rev);
94 echo "<div class='revinfo'>\n";
95 echo "Revision: $repo->shortname $ent->rev";
96 foreach ($ent->branches as $b) {
97 echo " " . mtrack_branch($b);
99 foreach ($ent->tags as $t) {
100 echo " " . mtrack_tag($t);
105 echo MTrackWiki::format_to_html($data->changelog);
107 echo "<div class='changeinfo'>\n";
108 echo mtrack_username($ent->changeby, array('size' => 32)) . "<br>\n";
109 echo mtrack_date($ent->ctime, true) . "<br>\n";
111 if (count($rdata->parents)) {
113 foreach ($rdata->parents as $p) {
114 echo " " . mtrack_changeset($p, $repo);
119 if (count($rdata->kids)) {
121 foreach ($rdata->kids as $kid) {
122 echo " " . mtrack_changeset($kid, $repo);
129 if (is_array($ent->files) && count($ent->files)) {
130 echo "<br><br><a href='${ABSWEB}changeset.php$path?fmt=diff'>Download diff</a>";
131 echo "<div class='difffiles'>Affected files:<ul>";
132 foreach ($ent->files as $id => $file) {
133 echo "<li><a href='#d$id'><b>$file->status</b> $file->name</a></li>\n";
137 foreach ($ent->files as $id => $file) {
138 $fpath = $file->name;
139 if ($fpath[0] != '/') $fpath = '/' . $fpath;
140 echo "<a name='d$id'></a><a href='{$ABSWEB}file.php/{$repo->getBrowseRootName()}$fpath?rev=$ent->rev'>$file</a><br>\n";
141 $diff = $file->diff; // populated in get_change_data
142 if ($diff === null) {
143 echo "No diff available. File status is <b>$file->status</b><br><br>";