Author: acydburn
Date: Sun Sep 20 17:20:20 2009
New Revision: 10168
Log:
improve code to detect and solve conflicts for code removed from one version to another.
Modified:
branches/phpBB-3_0_0/phpBB/includes/diff/diff.php
Modified: branches/phpBB-3_0_0/phpBB/includes/diff/diff.php
==============================================================================
*** branches/phpBB-3_0_0/phpBB/includes/diff/diff.php (original)
--- branches/phpBB-3_0_0/phpBB/includes/diff/diff.php Sun Sep 20 17:20:20 2009
***************
*** 997,1026 ****
// 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)
{
// First of all, try to find the code in orig in final1. ;)
$compare_seq = sizeof($this->orig);
! $begin = -1;
! $j = $end = 0;
! foreach ($this->final1 as $i => $line)
{
if (trim($line) === trim($this->orig[$j]))
{
if ($begin === -1)
{
$begin = $i;
}
if (isset($this->orig[$j+1]))
{
$j++;
}
}
-
- if ($begin !== -1)
- {
- $end++;
- }
}
if ($begin !== -1 && $begin + ($compare_seq - 1) == $end)
--- 997,1034 ----
// 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)
{
+ $result = $this->_compare_conflict_seq('orig', 'final1');
+
+ if (!$result['merge_found'])
+ {
+ return;
+ }
+
// First of all, try to find the code in orig in final1. ;)
$compare_seq = sizeof($this->orig);
! $begin = $end = -1;
! $j = 0;
! for ($i = 0, $size = sizeof($this->final1); $i < $size; $i++)
{
+ $line = $this->final1[$i];
+
if (trim($line) === trim($this->orig[$j]))
{
+ // Mark begin
if ($begin === -1)
{
$begin = $i;
}
+ // End is always $i, the last found line
+ $end = $i;
+
if (isset($this->orig[$j+1]))
{
$j++;
}
}
}
if ($begin !== -1 && $begin + ($compare_seq - 1) == $end)
|