1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-24 03:54:10 +01:00

phpBB updater now solves common conflicts on it's own. This further reduces the chance of conflicts.

(tested with some heavily modified files who previously generated a lot of conflicts)

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10160 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2009-09-17 14:18:57 +00:00
parent 13e8898563
commit d1f796bf25
2 changed files with 96 additions and 0 deletions

View File

@ -244,6 +244,7 @@
<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>[Change] phpBB updater now solves common conflicts on it's own. This further reduces the chance of conflicts.</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>

View File

@ -727,7 +727,9 @@ class diff3_op
}
else
{
// The following tries to aggressively solve conflicts...
$this->_merged = false;
$this->solve_conflict();
}
}
@ -738,6 +740,99 @@ class diff3_op
{
return ($this->merged() === false) ? true : false;
}
/**
* Tries to solve conflicts aggressively based on typical "assumptions"
* @author acydburn
*/
function solve_conflict()
{
$this->_merged = false;
// CASE ONE: orig changed into final2, but modified/unknown code in final1.
// IF orig is found "as is" in final1 we replace the code directly in final1 and populate this as final2/merge
if (sizeof($this->orig) && sizeof($this->final2))
{
// Ok, we basically search for $this->orig in $this->final1 and replace it with $this->final2
$compare_seq = sizeof($this->orig);
// Search for matching code block
$merge = array();
$merge_found = false;
// Go through the conflict code
for ($i = 0, $j = 0, $size = sizeof($this->final1); $i < $size; $i++, $j = $i)
{
$line = $this->final1[$i];
$skip = 0;
for ($x = 0; $x < $compare_seq; $x++)
{
// Try to skip all matching lines
if (trim($line) === trim($this->orig[$x]))
{
$line = (++$j < $size) ? $this->final1[$j] : $line;
$skip++;
}
}
if ($skip === $compare_seq)
{
$merge_found = true;
$merge = array_merge($merge, $this->final2);
$i += ($skip - 1);
}
else
{
$merge[] = $line;
}
}
if ($merge_found)
{
$this->final2 = $merge;
$this->_merged = &$this->final2;
}
return;
}
// CASE TWO: Added lines from orig to final2 but final1 had added lines too. Just merge them.
if (!sizeof($this->orig) && $this->final1 !== $this->final2 && sizeof($this->final1) && sizeof($this->final2))
{
$this->final2 = array_merge($this->final1, $this->final2);
$this->_merged = &$this->final2;
return;
}
// CASE THREE: Removed lines (orig has the to-remove line(s), but final1 has additional lines which does not need to be removed). Just remove orig from final1 and then use final1 as final2/merge
if (!sizeof($this->final2) && sizeof($this->orig) && sizeof($this->final1) && $this->orig !== $this->final1)
{
$merged = $this->final1;
foreach ($this->final1 as $i => $line)
{
foreach ($this->orig as $j => $old_line)
{
if (trim($line) === trim($old_line))
{
unset($merged[$i]);
}
}
}
if (sizeof($merged))
{
$this->final2 = array_values($merged);
$this->_merged = &$this->final2;
}
return;
}
return;
}
}
/**