Rev 3521: Fix the failing test by implementing the fallback logic. in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/weave_merge
John Arbash Meinel
john at arbash-meinel.com
Thu Jul 10 21:22:49 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/weave_merge
------------------------------------------------------------
revno: 3521
revision-id: john at arbash-meinel.com-20080710202241-7se48gbsuxm7ih4h
parent: john at arbash-meinel.com-20080710185429-w5k3hqv7dfpc9o2b
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: weave_merge
timestamp: Thu 2008-07-10 15:22:41 -0500
message:
Fix the failing test by implementing the fallback logic.
-------------- next part --------------
=== modified file 'bzrlib/merge.py'
--- a/bzrlib/merge.py 2008-07-09 23:21:13 +0000
+++ b/bzrlib/merge.py 2008-07-10 20:22:41 +0000
@@ -591,7 +591,7 @@
"""
result = []
iterator = self.other_tree.iter_changes(self.base_tree,
- include_unchanged=True, specific_files=self.interesting_files,
+ include_unchanged=False, specific_files=self.interesting_files,
extra_trees=[self.this_tree])
for (file_id, paths, changed, versioned, parents, names, kind,
executable) in iterator:
@@ -1442,9 +1442,55 @@
elif len(next_lcas) == 1:
parent_map[next_lcas.pop()] = ()
break
+ else:
+ # More than 2 lca's, fall back to grabbing all nodes between
+ # this and the unique lca.
+ mutter('More than 2 LCAs, falling back to all nodes for: %s',
+ cur_ancestors)
+ cur_lcas = next_lcas
+ while len(cur_lcas) > 1:
+ cur_lcas = self.graph.find_lca(*cur_lcas)
+ if len(cur_lcas) == 0:
+ # No common base to find, use the full ancestry
+ unique_lca = None
+ else:
+ unique_lca = cur_lcas.pop()
+ parent_map.update(self._find_unique_parents(next_lcas,
+ unique_lca))
+ break
cur_ancestors = next_lcas
return parent_map
+ def _find_unique_parents(self, tip_keys, base_key):
+ """Find ancestors of tip that aren't ancestors of base.
+
+ :param tip_keys: Nodes that are interesting
+ :param base_key: Cull all ancestors of this node
+ :return: The parent map for all revisions between tip_keys and
+ base_key. base_key will be included. References to nodes outside of
+ the ancestor set will also be removed.
+ """
+ # TODO: (performance) We could also "collapse" the graph at this point,
+ # to remove uninteresting linear chains of revisions.
+ # TODO: this would be simpler if find_unique_ancestors took a list
+ # instead of a single tip, internally it supports it, but it
+ # isn't a "backwards compatible" api change.
+ if base_key is None:
+ parent_map = dict(self.graph.iter_ancestry(tip_keys))
+ else:
+ interesting = set()
+ for tip in tip_keys:
+ interesting.update(
+ self.graph.find_unique_ancestors(tip, [base_key]))
+ parent_map = self.graph.get_parent_map(interesting)
+ parent_map[base_key] = ()
+ culled_parent_map = {}
+ for key, parent_keys in parent_map.iteritems():
+ culled_parent_keys = tuple([p for p in parent_keys
+ if p in parent_map])
+ culled_parent_map[key] = culled_parent_keys
+ return culled_parent_map
+
def _get_interesting_texts(self, parent_map):
"""Return a dict of texts we are interested in.
=== modified file 'bzrlib/tests/test_merge.py'
--- a/bzrlib/tests/test_merge.py 2008-07-10 18:54:29 +0000
+++ b/bzrlib/tests/test_merge.py 2008-07-10 20:22:41 +0000
@@ -596,6 +596,7 @@
self.assertEqual([
('unchanged', 'h\n'),
('unchanged', 'a\n'),
+ ('killed-base', 'b\n'),
('killed-b', 'x\n'),
('new-b', 'z\n'),
('unchanged', 'c\n'),
More information about the bazaar-commits
mailing list