diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2009-09-17 08:14:56 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2009-09-17 08:14:56 +0000 |
commit | 0b0c9544a33b8daee65b8173f2895d43a34c7e69 (patch) | |
tree | 05e7413078688f140cf4993ed12feb4e3e0a72bc | |
parent | 6b5d195a980145011800125f44466ab4823654f2 (diff) | |
download | forums-0b0c9544a33b8daee65b8173f2895d43a34c7e69.tar forums-0b0c9544a33b8daee65b8173f2895d43a34c7e69.tar.gz forums-0b0c9544a33b8daee65b8173f2895d43a34c7e69.tar.bz2 forums-0b0c9544a33b8daee65b8173f2895d43a34c7e69.tar.xz forums-0b0c9544a33b8daee65b8173f2895d43a34c7e69.zip |
found a much better method to skip whitespace/tab changes. :)
This also solves even more unncessary conflicts - Bug #51365
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10157 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r-- | phpBB/docs/CHANGELOG.html | 2 | ||||
-rw-r--r-- | phpBB/includes/diff/engine.php | 27 |
2 files changed, 9 insertions, 20 deletions
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index 6d34d05f27..f79c7c7a9b 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -243,7 +243,7 @@ <li>[Change] Do not take edit post time into account for determining permission to delete last post in topic. (Bug #48615)</li> <li>[Change] Resize oversized Topic icons (Bug #44415)</li> <li>[Change] Banned IPs are now sorted (Bug #43045 - Patch by DavidIQ)</li> - <li>[Change] phpBB updater now skips sole whitespace changes. This reduces the chance of conflicts tremendously.</li> + <li>[Change] phpBB updater now skips sole whitespace/tab changes while computing differences. This reduces the chance of conflicts tremendously.</li> <li>[Feature] Add language selection on the registration terms page (Bug #15085 - Patch by leviatan21)</li> <li>[Feature] Backported 3.2 captcha plugins. <ul> diff --git a/phpBB/includes/diff/engine.php b/phpBB/includes/diff/engine.php index e9f0e41b75..da7b4344a3 100644 --- a/phpBB/includes/diff/engine.php +++ b/phpBB/includes/diff/engine.php @@ -49,6 +49,9 @@ if (!defined('IN_PHPBB')) */ class diff_engine { + /** + * If set to true we trim all lines before we compare them. This ensures that sole space/tab changes do not trigger diffs. + */ var $skip_whitespace_changes = true; function diff(&$from_lines, &$to_lines, $preserve_cr = true) @@ -87,7 +90,7 @@ class diff_engine // Skip leading common lines. for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) { - if ($from_lines[$skip] !== $to_lines[$skip]) + if (trim($from_lines[$skip]) !== trim($to_lines[$skip])) { break; } @@ -100,7 +103,7 @@ class diff_engine for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) { - if ($from_lines[$xi] !== $to_lines[$yi]) + if (trim($from_lines[$xi]) !== trim($to_lines[$yi])) { break; } @@ -110,12 +113,12 @@ class diff_engine // Ignore lines which do not exist in both files. for ($xi = $skip; $xi < $n_from - $endskip; $xi++) { - $xhash[$from_lines[$xi]] = 1; + if ($this->skip_whitespace_changes) $xhash[trim($from_lines[$xi])] = 1; else $xhash[$from_lines[$xi]] = 1; } for ($yi = $skip; $yi < $n_to - $endskip; $yi++) { - $line = $to_lines[$yi]; + $line = ($this->skip_whitespace_changes) ? trim($to_lines[$yi]) : $to_lines[$yi]; if (($this->ychanged[$yi] = empty($xhash[$line]))) { @@ -128,7 +131,7 @@ class diff_engine for ($xi = $skip; $xi < $n_from - $endskip; $xi++) { - $line = $from_lines[$xi]; + $line = ($this->skip_whitespace_changes) ? trim($from_lines[$xi]) : $from_lines[$xi]; if (($this->xchanged[$xi] = empty($yhash[$line]))) { @@ -178,20 +181,6 @@ class diff_engine $add[] = $to_lines[$yi++]; } - // Here we are a bit naughty. Naughty Boy... Naughty Boy... - // We check if delete and add is filled and only consist of one item - if ($this->skip_whitespace_changes && sizeof($delete) == 1 && sizeof($add) == 1) - { - // Now we simply trim the string and see if the lines are identical - // If they are identical we do not need to take them into account for the merge (less conflicts in phpBB) - if (trim($delete[0]) === trim($add[0])) - { - // This line ensures the line found here is correctly copied later (remember: we naughty boys like loops) - $xi--; $yi--; $this->xchanged[$xi] = $this->ychanged[$yi] = false; - $delete = $add = array(); - } - } - if ($delete && $add) { $edits[] = new diff_op_change($delete, $add); |