From 97be42d31c50efb248086c7147e6e768154404a4 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 20 Sep 2009 16:20:20 +0000 Subject: [PATCH] improve code to detect and solve conflicts for code removed from one version to another. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10168 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/diff/diff.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/diff/diff.php b/phpBB/includes/diff/diff.php index 6bda3df43e..60af574b78 100644 --- a/phpBB/includes/diff/diff.php +++ b/phpBB/includes/diff/diff.php @@ -997,30 +997,38 @@ class diff3_op // 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 = -1; - $j = $end = 0; + $begin = $end = -1; + $j = 0; - foreach ($this->final1 as $i => $line) + 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) - { - $end++; - } } if ($begin !== -1 && $begin + ($compare_seq - 1) == $end)