diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2009-09-17 14:18:57 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2009-09-17 14:18:57 +0000 |
commit | d1f796bf255ea92aad1070293cf41a892a8245bf (patch) | |
tree | 7d15343f1177788b9c32e2973b4d99271525893c /phpBB | |
parent | 13e8898563365d93525f08e1b4103c94b2114d48 (diff) | |
download | forums-d1f796bf255ea92aad1070293cf41a892a8245bf.tar forums-d1f796bf255ea92aad1070293cf41a892a8245bf.tar.gz forums-d1f796bf255ea92aad1070293cf41a892a8245bf.tar.bz2 forums-d1f796bf255ea92aad1070293cf41a892a8245bf.tar.xz forums-d1f796bf255ea92aad1070293cf41a892a8245bf.zip |
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
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/docs/CHANGELOG.html | 1 | ||||
-rw-r--r-- | phpBB/includes/diff/diff.php | 95 |
2 files changed, 96 insertions, 0 deletions
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index f79c7c7a9b..32b3548227 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -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> diff --git a/phpBB/includes/diff/diff.php b/phpBB/includes/diff/diff.php index 2adc3a3e6e..d8ee43feec 100644 --- a/phpBB/includes/diff/diff.php +++ b/phpBB/includes/diff/diff.php @@ -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; + } } /** |