From: Meik S. <acy...@ph...> - 2009-09-17 08:15:42
|
Author: acydburn Date: Thu Sep 17 09:14:56 2009 New Revision: 10157 Log: found a much better method to skip whitespace/tab changes. :) This also solves even more unncessary conflicts - Bug #51365 Modified: branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html branches/phpBB-3_0_0/phpBB/includes/diff/engine.php Modified: branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html ============================================================================== *** branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html (original) --- branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html Thu Sep 17 09:14:56 2009 *************** *** 243,249 **** <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>[Feature] Add language selection on the registration terms page (Bug #15085 - Patch by leviatan21)</li> <li>[Feature] Backported 3.2 captcha plugins. <ul> --- 243,249 ---- <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/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> Modified: branches/phpBB-3_0_0/phpBB/includes/diff/engine.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/includes/diff/engine.php (original) --- branches/phpBB-3_0_0/phpBB/includes/diff/engine.php Thu Sep 17 09:14:56 2009 *************** *** 49,54 **** --- 49,57 ---- */ 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,93 **** // Skip leading common lines. for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) { ! if ($from_lines[$skip] !== $to_lines[$skip]) { break; } --- 90,96 ---- // Skip leading common lines. for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) { ! if (trim($from_lines[$skip]) !== trim($to_lines[$skip])) { break; } *************** *** 100,106 **** for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) { ! if ($from_lines[$xi] !== $to_lines[$yi]) { break; } --- 103,109 ---- for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) { ! if (trim($from_lines[$xi]) !== trim($to_lines[$yi])) { break; } *************** *** 110,121 **** // Ignore lines which do not exist in both files. for ($xi = $skip; $xi < $n_from - $endskip; $xi++) { ! $xhash[$from_lines[$xi]] = 1; } for ($yi = $skip; $yi < $n_to - $endskip; $yi++) { ! $line = $to_lines[$yi]; if (($this->ychanged[$yi] = empty($xhash[$line]))) { --- 113,124 ---- // Ignore lines which do not exist in both files. for ($xi = $skip; $xi < $n_from - $endskip; $xi++) { ! 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 = ($this->skip_whitespace_changes) ? trim($to_lines[$yi]) : $to_lines[$yi]; if (($this->ychanged[$yi] = empty($xhash[$line]))) { *************** *** 128,134 **** for ($xi = $skip; $xi < $n_from - $endskip; $xi++) { ! $line = $from_lines[$xi]; if (($this->xchanged[$xi] = empty($yhash[$line]))) { --- 131,137 ---- for ($xi = $skip; $xi < $n_from - $endskip; $xi++) { ! $line = ($this->skip_whitespace_changes) ? trim($from_lines[$xi]) : $from_lines[$xi]; if (($this->xchanged[$xi] = empty($yhash[$line]))) { *************** *** 178,197 **** $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); --- 181,186 ---- |