Skip to content

Commit

Permalink
added option to ignore whitespaces in diff per default
Browse files Browse the repository at this point in the history
modified prev/next/youngest links to keep current whitespace setting
  • Loading branch information
dirk-thomas committed Jun 25, 2011
1 parent d4bb53a commit b986537
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
25 changes: 18 additions & 7 deletions diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@

$vars['action'] = $lang['DIFF'];
$all = (@$_REQUEST['all'] == 1);
$ignoreWhitespace = (@$_REQUEST['ignorews'] == 1);
$ignoreWhitespace = $config->getIgnoreWhitespacesInDiff();
if (array_key_exists('ignorews', $_REQUEST)) {
$ignoreWhitespace = (bool)$_REQUEST['ignorews'];
}

// Make sure that we have a repository
if ($rep) {
Expand Down Expand Up @@ -77,8 +80,13 @@
createPathLinks($rep, $ppath, $passrev, $peg);
$passRevString = createRevAndPegString($rev, $peg);

$passIgnoreWhitespace = '';
if ($ignoreWhitespace != $config->getIgnoreWhitespacesInDiff()) {
$passIgnoreWhitespace = '&ignorews='.($ignoreWhitespace ? '1' : '0');
}

if ($rev != $youngest) {
$vars['goyoungesturl'] = $config->getURL($rep, $path, 'diff').createRevAndPegString('', $peg);
$vars['goyoungesturl'] = $config->getURL($rep, $path, 'diff').createRevAndPegString('', $peg).$passIgnoreWhitespace;
$vars['goyoungestlink'] = '<a href="'.$vars['goyoungesturl'].'"'.($youngest ? ' title="'.$lang['REV'].' '.$youngest.'"' : '').'>'.$lang['GOYOUNGEST'].'</a>';
}

Expand All @@ -89,7 +97,7 @@
$nextRev = $history2->entries[1]->rev;
if ($nextRev != $youngest) {
$vars['nextrev'] = $nextRev;
$vars['nextrevurl'] = $revurl.createRevAndPegString($nextRev, $peg);
$vars['nextrevurl'] = $revurl.createRevAndPegString($nextRev, $peg).$passIgnoreWhitespace;
}
}
unset($vars['error']);
Expand All @@ -99,7 +107,7 @@
$prevRev = $history->entries[1]->rev;
$prevPath = $history->entries[1]->path;
$vars['prevrev'] = $prevRev;
$vars['prevrevurl'] = $revurl.createRevAndPegString($prevRev, $peg);
$vars['prevrevurl'] = $revurl.createRevAndPegString($prevRev, $peg).$passIgnoreWhitespace;
}

$vars['revurl'] = $config->getURL($rep, $path, 'revision').$passRevString;
Expand Down Expand Up @@ -132,17 +140,20 @@
} else {
$diff = $config->getURL($rep, $path, 'diff').$passRevString;

$passIgnoreWhitespace = ($ignoreWhitespace ? '&amp;ignorews=1' : '');
if ($all) {
$vars['showcompactlink'] = '<a href="'.$diff.$passIgnoreWhitespace.'">'.$lang['SHOWCOMPACT'].'</a>';
} else {
$vars['showalllink'] = '<a href="'.$diff.$passIgnoreWhitespace.'&amp;all=1'.'">'.$lang['SHOWENTIREFILE'].'</a>';
}
$passShowAll = ($all ? '&amp;all=1' : '');
$toggleIgnoreWhitespace = '';
if ($ignoreWhitespace == $config->getIgnoreWhitespacesInDiff()) {
$toggleIgnoreWhitespace = '&amp;ignorews='.($ignoreWhitespace ? '0' : '1');
}
if ($ignoreWhitespace) {
$vars['regardwhitespacelink'] = '<a href="'.$diff.$passShowAll.'">'.$lang['REGARDWHITESPACE'].'</a>';
$vars['regardwhitespacelink'] = '<a href="'.$diff.$passShowAll.$toggleIgnoreWhitespace.'">'.$lang['REGARDWHITESPACE'].'</a>';
} else {
$vars['ignorewhitespacelink'] = '<a href="'.$diff.$passShowAll.'&amp;ignorews=1">'.$lang['IGNOREWHITESPACE'].'</a>';
$vars['ignorewhitespacelink'] = '<a href="'.$diff.$passShowAll.$toggleIgnoreWhitespace.'">'.$lang['IGNOREWHITESPACE'].'</a>';
}

// Get the contents of the two files
Expand Down
9 changes: 9 additions & 0 deletions include/configclass.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ class WebSvnConfig {
var $showLastModInListing = true;
var $showAgeInsteadOfDate = true;
var $_showRepositorySelectionForm = true;
var $_ignoreWhitespacesInDiff = false;
var $serverIsWindows = false;
var $multiViews = false;
var $useEnscript = false;
Expand Down Expand Up @@ -1551,6 +1552,14 @@ function setShowRepositorySelectionForm($show) {
$this->_showRepositorySelectionForm = $show;
}

function getIgnoreWhitespacesInDiff() {
return $this->_ignoreWhitespacesInDiff;
}

function setIgnoreWhitespacesInDiff($ignore) {
$this->_ignoreWhitespacesInDiff = $ignore;
}

// Methods for storing version information for the command-line svn tool

function setSubversionVersion($subversionVersion) {
Expand Down
5 changes: 5 additions & 0 deletions include/distconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@

// $config->setShowRepositorySelectionForm(false);

// By default, WebSVN does not ignore whitespaces when showing diffs.
// To enable ignoring whitespaces in diffs per default uncomment this line.

// $config->setIgnoreWhitespacesInDiff(true);

// }}}

// {{{ LANGUAGE SETUP ---
Expand Down

0 comments on commit b986537

Please sign in to comment.