jablonka.czprosek.czf

websvn

Subversion Repositories:
[/] [diff.php] - Blame information for rev 3

 

Line No. Rev Author Line
11simandl<?php
2// WebSVN - Subversion repository viewing via the web using PHP
3// Copyright (C) 2004-2006 Tim Armes
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18//
19// --
20//
21// diff.php
22//
23// Show the differences between 2 revisions of a file.
24//
25 
26require_once("include/setup.php");
27require_once("include/svnlook.php");
28require_once("include/utils.php");
29require_once("include/template.php");
30 
313simandlrequire_once("include/diff_inc.php");
321simandl 
33$vars["action"] = $lang["DIFF"];
343simandl$all = (@$_REQUEST["all"] == 1);
35$ignoreWhitespace = (@$_REQUEST["ignorews"] == 1);
361simandl 
37// Make sure that we have a repository
38if (!isset($rep)) {
39 echo $lang["NOREP"];
40 exit;
41}
42 
43$svnrep = new SVNRepository($rep);
44 
45// If there's no revision info, go to the lastest revision for this path
46$history = $svnrep->getLog($path, "", "", true);
473simandlif (is_string($history)) {
48 echo $history;
49 exit;
50}
511simandl$youngest = $history->entries[0]->rev;
52 
53if (empty($rev)) {
54 $rev = $youngest;
55}
56 
57$history = $svnrep->getLog($path, $rev);
583simandlif (is_string($history)) {
59 echo $history;
60 exit;
61}
621simandl 
63if ($path{0} != "/") {
64 $ppath = "/".$path;
65} else {
66 $ppath = $path;
67}
68 
69$prevrev = @$history->entries[1]->rev;
70 
71$vars["repname"] = htmlentities($rep->getDisplayName(), ENT_QUOTES, 'UTF-8');
72$vars["rev"] = $rev;
73$vars["path"] = htmlentities($ppath, ENT_QUOTES, 'UTF-8');
74$vars["prevrev"] = $prevrev;
75 
76$vars["rev1"] = $history->entries[0]->rev;
77$vars["rev2"] = $prevrev;
78 
79createDirLinks($rep, $ppath, $rev);
80 
81$listing = array();
82 
83$url = $config->getURL($rep, $path, "file");
84if ($rev != $youngest) {
85 $vars["goyoungestlink"] = '<a href="'.$url.'">'.$lang['GOYOUNGEST'].'</a>';
86} else {
87 $vars["goyoungestlink"] = "";
88}
89 
90$vars['indexurl'] = $config->getURL($rep, '', 'index');
91$vars['repurl'] = $config->getURL($rep, '', 'dir');
92 
93$url = $config->getURL($rep, $path, "file");
94$vars["filedetaillink"] = "<a href=\"${url}rev=$rev&amp;isdir=0\">${lang["FILEDETAIL"]}</a>";
95 
96$url = $config->getURL($rep, $path, "log");
97$vars["fileviewloglink"] = "<a href=\"${url}rev=$rev&amp;isdir=0\">${lang["VIEWLOG"]}</a>";
98 
99$url = $config->getURL($rep, $path, "diff");
100$vars["prevdifflink"] = "<a href=\"${url}rev=$rev\">${lang["DIFFPREV"]}</a>";
101 
102$url = $config->getURL($rep, $path, "blame");
103$vars["blamelink"] = "<a href=\"${url}rev=$rev\">${lang["BLAME"]}</a>";
104 
105if ($prevrev) {
106 $url = $config->getURL($rep, $path, "diff");
107 
108 if (!$all) {
1093simandl $vars["showalllink"] = '<a href="'.$url.'rev='.$rev.'&amp;all=1&amp;ignorews='.($ignoreWhitespace ? '1' : '0').'">'.$lang['SHOWENTIREFILE'].'</a>';
110 $vars["showcompactlink"] = '';
1111simandl } else {
1123simandl $vars["showcompactlink"] = '<a href="'.$url.'rev='.$rev.'&amp;all=0&amp;ignorews='.($ignoreWhitespace ? '1' : '0').'">'.$lang['SHOWCOMPACT'].'</a>';
113 $vars["showalllink"] = '';
1141simandl }
1153simandl if (!$ignoreWhitespace) {
116 $vars['ignorewhitespacelink'] = '<a href="'.$url.'rev='.$rev.'&amp;all='.($all ? '1' : '0').'&amp;ignorews=1">'.$lang['IGNOREWHITESPACE'].'</a>';
117 $vars['regardwhitespacelink'] = '';
118 } else {
119 $vars['regardwhitespacelink'] = '<a href="'.$url.'rev='.$rev.'&amp;all='.($all ? '1' : '0').'&amp;ignorews=0">'.$lang['REGARDWHITESPACE'].'</a>';
120 $vars['ignorewhitespacelink'] = '';
121 }
1221simandl 
123 // Get the contents of the two files
124 $newtname = tempnam("temp", "");
1253simandl $highlightedNew = $svnrep->getFileContents($history->entries[0]->path, $newtname, $history->entries[0]->rev, "", true);
1261simandl 
127 $oldtname = tempnam("temp", "");
1283simandl $highlightedOld = $svnrep->getFileContents($history->entries[1]->path, $oldtname, $history->entries[1]->rev, "", true);
1291simandl 
1303simandl $ent = (!$highlightedNew && !$highlightedOld);
131 $listing = do_diff($all, $ignoreWhitespace, $rep, $ent, $newtname, $oldtname);
1321simandl 
133 // Remove our temporary files
134 @unlink($oldtname);
135 @unlink($newtname);
136 
137} else {
138 $vars["noprev"] = 1;
139 $url = $config->getURL($rep, $path, "file");
140 $vars["filedetaillink"] = "<a href=\"${url}rev=$rev\">${lang["SHOWENTIREFILE"]}.</a>";
141}
142 
143$vars["version"] = $version;
144 
145if (!$rep->hasReadAccess($path, false)) {
146 $vars["noaccess"] = true;
147}
148 
149parseTemplate($rep->getTemplatePath()."header.tmpl", $vars, $listing);
150parseTemplate($rep->getTemplatePath()."diff.tmpl", $vars, $listing);
151parseTemplate($rep->getTemplatePath()."footer.tmpl", $vars, $listing);

Powered by WebSVN 2.2.1