websvn |
Subversion Repositories: |
Rev 1 | Rev 3 | |
---|---|---|
Line 52... | Line 52... | |
// Retrieve the request information |
// Retrieve the request information | |
$path1 = @$_REQUEST["compare"][0]; |
$path1 = @$_REQUEST["compare"][0]; | |
$path2 = @$_REQUEST["compare"][1]; |
$path2 = @$_REQUEST["compare"][1]; | |
$rev1 = (int)@$_REQUEST["compare_rev"][0]; |
$rev1 = (int)@$_REQUEST["compare_rev"][0]; | |
$rev2 = (int)@$_REQUEST["compare_rev"][1]; |
$rev2 = (int)@$_REQUEST["compare_rev"][1]; | |
$manualorder = (@$_REQUEST["manualorder"] == 1); | ||
$ignoreWhitespace = (@$_REQUEST["ignorews"] == 1); | ||
|
| |
// Some page links put the revision with the path... |
// Some page links put the revision with the path... | |
if (strpos($path1, "@")) list($path1, $rev1) = explode("@", $path1); |
if (strpos($path1, "@")) list($path1, $rev1) = explode("@", $path1); | |
// Something went wrong. The path is missing. | ||
else if (strpos($path1, "@") === 0) { | ||
$rev1 = substr($path1, 1); | ||
$path1 = '/'; | ||
} | ||
if (strpos($path2, "@")) list($path2, $rev2) = explode("@", $path2); |
if (strpos($path2, "@")) list($path2, $rev2) = explode("@", $path2); | |
else if (strpos($path2, "@") === 0) { | ||
$rev2 = substr($path2, 1); | ||
$path2 = '/'; | ||
} | ||
|
| |
$rev1 = checkRevision($rev1); |
$rev1 = checkRevision($rev1); | |
$rev2 = checkRevision($rev2); |
$rev2 = checkRevision($rev2); | |
|
| |
// Choose a sensible comparison order unless told not to |
// Choose a sensible comparison order unless told not to | |
if (!@$_REQUEST["manualorder"] && is_numeric($rev1) && is_numeric($rev2)) { |
||
if ($rev1 > $rev2) { |
||
$temppath = $path1; |
||
$temprev = $rev1; |
||
|
| |
$path1 = $path2; |
if (!$manualorder && is_numeric($rev1) && is_numeric($rev2) && $rev1 > $rev2) { | |
$rev1 = $rev2; |
$temppath = $path1; | |
$temprev = $rev1; | ||
|
| |
$path2 = $temppath; |
$path1 = $path2; | |
$rev2 = $temprev; |
$rev1 = $rev2; | |
} |
| |
$path2 = $temppath; | ||
$rev2 = $temprev; | ||
} |
} | |
|
| |
$vars['indexurl'] = $config->getURL($rep, '', 'index'); |
$vars['indexurl'] = $config->getURL($rep, '', 'index'); | |
$vars['repurl'] = $config->getURL($rep, '', 'dir'); |
$vars['repurl'] = $config->getURL($rep, '', 'dir'); | |
|
| |
$url = $config->getURL($rep, "/", "comp"); |
$url = $config->getURL($rep, "/", "comp"); | |
$vars["revlink"] = "<a href=\"${url}compare%5B%5D=".urlencode($path2)."@$rev2&compare%5B%5D=".urlencode($path1)."@$rev1&manualorder=1\">${lang["REVCOMP"]}</a>"; |
$vars["revlink"] = '<a href="'.$url.'compare%5B%5D='.urlencode($path2).'@'.$rev2.'&compare%5B%5D='.urlencode($path1).'@'.$rev1.'&manualorder=1&ignorews='.($ignoreWhitespace ? '1' : '0').'">'.$lang['REVCOMP'].'</a>'; | |
if (!$ignoreWhitespace) { | ||
$vars['ignorewhitespacelink'] = '<a href="'.$url.'compare%5B%5D='.urlencode($path1).'@'.$rev1.'&compare%5B%5D='.urlencode($path2).'@'.$rev2.'&manualorder='.($manualorder ? '1' : '0').'&ignorews=1">'.$lang['IGNOREWHITESPACE'].'</a>'; | ||
$vars['regardwhitespacelink'] = ''; | ||
} else { | ||
$vars['regardwhitespacelink'] = '<a href="'.$url.'compare%5B%5D='.urlencode($path1).'@'.$rev1.'&compare%5B%5D='.urlencode($path2).'@'.$rev2.'&manualorder='.($manualorder ? '1' : '0').'&ignorews=0">'.$lang['REGARDWHITESPACE'].'</a>'; | ||
$vars['ignorewhitespacelink'] = ''; | ||
} | ||
|
| |
if ($rev1 == 0) $rev1 = "HEAD"; |
if ($rev1 == 0) $rev1 = "HEAD"; | |
if ($rev2 == 0) $rev2 = "HEAD"; |
if ($rev2 == 0) $rev2 = "HEAD"; | |
|
| |
$vars["repname"] = $rep->getDisplayName(); |
$vars["repname"] = $rep->getDisplayName(); | |
Line 111... | Line 128... | |
// Generate the diff listing |
// Generate the diff listing | |
|
| |
$relativePath1 = $path1; |
$relativePath1 = $path1; | |
$relativePath2 = $path2; |
$relativePath2 = $path2; | |
|
| |
$path1 = encodepath(str_replace(DIRECTORY_SEPARATOR, "/", $svnrep->repConfig->path.$path1)); |
$svnpath1 = encodepath($svnrep->getSvnpath(str_replace(DIRECTORY_SEPARATOR, '/', $path1))); | |
$path2 = encodepath(str_replace(DIRECTORY_SEPARATOR, "/", $svnrep->repConfig->path.$path2)); |
$svnpath2 = encodepath($svnrep->getSvnpath(str_replace(DIRECTORY_SEPARATOR, '/', $path2))); | |
|
| |
$debug = false; |
$debug = false; | |
|
| |
if (!$noinput) { |
if (!$noinput) { | |
$rawcmd = $config->svn." diff ".$rep->svnParams().quote($path1."@".$rev1)." ".quote($path2."@".$rev2); |
$cmd = $config->svn." diff ".($ignoreWhitespace ? '-x -w ' : '').$rep->svnParams().quote($svnpath1."@".$rev1)." ".quote($svnpath2."@".$rev2); | |
$cmd = quoteCommand($rawcmd); |
||
if ($debug) echo "$cmd\n"; |
if ($debug) echo "$cmd\n"; | |
} |
} | |
|
| |
function clearVars() { |
function clearVars() { | |
global $listing, $index; |
global $listing, $index; | |
Line 137... | Line 153... | |
} |
} | |
|
| |
$vars["success"] = false; |
$vars["success"] = false; | |
|
| |
if (!$noinput) { |
if (!$noinput) { | |
if ($diff = popen($cmd, "r")) { |
if ($diff = popenCommand($cmd, "r")) { | |
$index = 0; |
$index = 0; | |
$indiff = false; |
$indiff = false; | |
$indiffproper = false; |
$indiffproper = false; | |
$getLine = true; |
$getLine = true; | |
$node = null; |
$node = null; | |
Line 172... | Line 188... | |
if ($indiff) { |
if ($indiff) { | |
// If we're in a diff proper, just set up the line |
// If we're in a diff proper, just set up the line | |
if ($indiffproper) { |
if ($indiffproper) { | |
if (strlen($line) > 0 && ($line[0] == " " || $line[0] == "+" || $line[0] == "-")) { |
if (strlen($line) > 0 && ($line[0] == " " || $line[0] == "+" || $line[0] == "-")) { | |
$subline = replaceEntities(substr($line, 1), $rep); |
$subline = replaceEntities(substr($line, 1), $rep); | |
if (empty($subline)) $subline = " "; |
if ($subline == '') $subline = " "; | |
$subline = hardspace($subline); |
$subline = hardspace($subline); | |
$listing[$index]["line"] = $subline; |
$listing[$index]["line"] = $subline; | |
|
| |
switch ($line[0]) { |
switch ($line[0]) { | |
case " ": |
case " ": | |
Line 213... | Line 229... | |
|
| |
// Check for the start of a new diff area |
// Check for the start of a new diff area | |
if (!strncmp($line, "@@", 2)) { |
if (!strncmp($line, "@@", 2)) { | |
$pos = strpos($line, "+"); |
$pos = strpos($line, "+"); | |
$posline = substr($line, $pos); |
$posline = substr($line, $pos); | |
$sline = 0; | ||
$eline = 0; | ||
sscanf($posline, "+%d,%d", $sline, $eline); |
sscanf($posline, "+%d,%d", $sline, $eline); | |
if ($debug) print "sline = '$sline', eline = '$eline'<br />"; |
if ($debug) print "sline = '$sline', eline = '$eline'<br />"; | |
// Check that this isn't a file deletion |
// Check that this isn't a file deletion | |
if ($sline == 0 && $eline == 0) { |
if ($sline == 0 && $eline == 0) { | |
$line = fgets($diff); |
$line = fgets($diff); | |
Line 230... | Line 248... | |
if ($debug) print "Unignoring previous - marking as deleted<b>"; |
if ($debug) print "Unignoring previous - marking as deleted<b>"; | |
$listing[$index++]["info"] = $lang["FILEDELETED"]; |
$listing[$index++]["info"] = $lang["FILEDELETED"]; | |
|
| |
} else { |
} else { | |
$listing[$index]["difflines"] = $line; |
$listing[$index]["difflines"] = $line; | |
$sline = 0; | ||
$slen = 0; | ||
$eline = 0; | ||
$elen = 0; | ||
sscanf($line, "@@ -%d,%d +%d,%d @@", $sline, $slen, $eline, $elen); |
sscanf($line, "@@ -%d,%d +%d,%d @@", $sline, $slen, $eline, $elen); | |
$listing[$index]["rev1line"] = $sline; |
$listing[$index]["rev1line"] = $sline; | |
$listing[$index]["rev1len"] = $slen; |
$listing[$index]["rev1len"] = $slen; | |
$listing[$index]["rev2line"] = $eline; |
$listing[$index]["rev2line"] = $eline; | |
$listing[$index]["rev2len"] = $elen; |
$listing[$index]["rev2len"] = $elen; | |
Line 261... | Line 283... | |
|
| |
$node = trim($line); |
$node = trim($line); | |
$node = substr($node, 7); |
$node = substr($node, 7); | |
if ($node == '' || $node{0} != '/') $node = '/'.$node; |
if ($node == '' || $node{0} != '/') $node = '/'.$node; | |
|
| |
$listing[$index]["newpath"] = $node; |
if (substr($path2, -strlen($node)) === $node) { | |
$absnode = $path2; | ||
} else { | ||
$absnode = $path2; | ||
if (substr($absnode, -1) == '/') $absnode = substr($absnode, 0, -1); | ||
$absnode .= $node; | ||
} | ||
| ||
$listing[$index]["newpath"] = $absnode; | ||
|
| |
$listing[$index]["fileurl"] = $config->getURL($rep, $node, "file").'rev='.$rev2; |
$listing[$index]["fileurl"] = $config->getURL($rep, $absnode, "file").'rev='.$rev2; | |
|
| |
if ($debug) echo "Creating node $node<br />"; |
if ($debug) echo "Creating node $node<br />"; | |
|
| |
// Skip past the line of ='s |
// Skip past the line of ='s | |
$line = fgets($diff); |
$line = fgets($diff); |