mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
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
This commit is contained in:
parent
6b5d195a98
commit
0b0c9544a3
2 changed files with 9 additions and 20 deletions
|
@ -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>
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue