Rev 3547: Handle when there are more than 2 LCAs while searching for the unique lca. in http://bzr.arbash-meinel.com/branches/bzr/1.7-dev/merge_lca_multi
John Arbash Meinel
john at arbash-meinel.com
Wed Jul 30 03:19:36 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.7-dev/merge_lca_multi
------------------------------------------------------------
revno: 3547
revision-id: john at arbash-meinel.com-20080730021916-65dpdenvz27emgnk
parent: john at arbash-meinel.com-20080729230216-xt8zje18edlwsnb7
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: merge_lca_multi
timestamp: Tue 2008-07-29 21:19:16 -0500
message:
Handle when there are more than 2 LCAs while searching for the unique lca.
-------------- next part --------------
=== modified file 'bzrlib/merge.py'
--- a/bzrlib/merge.py 2008-07-29 23:02:16 +0000
+++ b/bzrlib/merge.py 2008-07-30 02:19:16 +0000
@@ -363,8 +363,16 @@
elif len(lcas) == 1:
self.base_rev_id = list(lcas)[0]
else: # len(lcas) > 1
- self.base_rev_id = self.revision_graph.find_unique_lca(
- *lcas)
+ if len(lcas) > 2:
+ # find_unique_lca can only handle 2 nodes, so we have to
+ # start back at the beginning. It is a shame to traverse
+ # the graph again, but better than re-implementing
+ # find_unique_lca.
+ self.base_rev_id = self.revision_graph.find_unique_lca(
+ revisions[0], revisions[1])
+ else:
+ self.base_rev_id = self.revision_graph.find_unique_lca(
+ *lcas)
self._is_criss_cross = True
if self.base_rev_id == NULL_REVISION:
raise UnrelatedBranches()
=== modified file 'bzrlib/tests/test_merge.py'
--- a/bzrlib/tests/test_merge.py 2008-07-29 23:02:16 +0000
+++ b/bzrlib/tests/test_merge.py 2008-07-30 02:19:16 +0000
@@ -1176,6 +1176,24 @@
self.assertEqual(['C-id', 'B-id'], [t.get_revision_id()
for t in merger._lca_trees])
+ def test_find_base_triple_criss_cross(self):
+ # A-.
+ # / \ \
+ # B C F # F is merged into both branches
+ # |\ /| |
+ # | X | |\
+ # |/ \| | :
+ # : D E |
+ # \| |/
+ # G H
+ builder = self.setup_criss_cross_graph()
+ builder.build_snapshot('F-id', ['A-id'], [])
+ builder.build_snapshot('H-id', ['E-id', 'F-id'], [])
+ builder.build_snapshot('G-id', ['D-id', 'F-id'], [])
+ merger = self.make_Merger(builder, 'H-id')
+ self.assertEqual(['B-id', 'C-id', 'F-id'],
+ [t.get_revision_id() for t in merger._lca_trees])
+
def test_no_criss_cross_passed_to_merge_type(self):
class LCATreesMerger(LoggingMerger):
supports_lca_trees = True
More information about the bazaar-commits
mailing list