Rev 3525: Shortcut the case when one revision is in the ancestry of the other. in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/weave_merge
John Arbash Meinel
john at arbash-meinel.com
Fri Jul 11 22:41:31 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/weave_merge
------------------------------------------------------------
revno: 3525
revision-id: john at arbash-meinel.com-20080711214124-qi09irlj7pd5cuzg
parent: john at arbash-meinel.com-20080711212836-1ehghrnzgaioqwou
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: weave_merge
timestamp: Fri 2008-07-11 16:41:24 -0500
message:
Shortcut the case when one revision is in the ancestry of the other.
At the cost of a heads() check, when one parent supersedes, we don't have to extract
the text for the other. Changes merge time from 3m37s => 3m21s. Using a
CachingParentsProvider would drop the time down to 3m11s.
-------------- next part --------------
=== modified file 'bzrlib/merge.py'
--- a/bzrlib/merge.py 2008-07-11 21:28:36 +0000
+++ b/bzrlib/merge.py 2008-07-11 21:41:24 +0000
@@ -1400,22 +1400,22 @@
self.a_key = self._key_prefix + (self.a_rev,)
self.b_key = self._key_prefix + (self.b_rev,)
self.graph = Graph(self.vf)
- # heads = self.graph.heads((self.a_key, self.b_key))
- # if len(heads) == 1:
- # # one side dominates, so we can just return its values, yay for
- # # per-file graphs
- # # Ideally we would know that before we get this far
- # self._head_key = heads.pop()
- # if self._head_key == self.a_key:
- # other = b_rev
- # else:
- # other = a_rev
- # mutter('found dominating revision for %s\n%s > %s', self.vf,
- # self._head_key[-1], other)
- # self._weave = None
- # else:
- self._head_key = None
- self._build_weave()
+ heads = self.graph.heads((self.a_key, self.b_key))
+ if len(heads) == 1:
+ # one side dominates, so we can just return its values, yay for
+ # per-file graphs
+ # Ideally we would know that before we get this far
+ self._head_key = heads.pop()
+ if self._head_key == self.a_key:
+ other = b_rev
+ else:
+ other = a_rev
+ mutter('found dominating revision for %s\n%s > %s', self.vf,
+ self._head_key[-1], other)
+ self._weave = None
+ else:
+ self._head_key = None
+ self._build_weave()
def _precache_tip_lines(self):
# Turn this into a no-op, because we will do this later
=== modified file 'bzrlib/tests/test_merge.py'
--- a/bzrlib/tests/test_merge.py 2008-07-11 21:28:36 +0000
+++ b/bzrlib/tests/test_merge.py 2008-07-11 21:41:24 +0000
@@ -525,12 +525,14 @@
self.add_version(('root', 'D'),
[('root', 'A'), ('root', 'B'), ('root', 'C')], 'abcdegh')
my_plan = _PlanMerge('B', 'D', self.plan_merge_vf, ('root',))
+ # We shortcut when one text supersedes the other in the per-file graph.
+ # We don't actually need to compare the texts at this point.
self.assertEqual([
- ('unchanged', 'a\n'),
- ('unchanged', 'b\n'),
- ('unchanged', 'c\n'),
- ('unchanged', 'd\n'),
- ('unchanged', 'e\n'),
+ ('new-b', 'a\n'),
+ ('new-b', 'b\n'),
+ ('new-b', 'c\n'),
+ ('new-b', 'd\n'),
+ ('new-b', 'e\n'),
('new-b', 'g\n'),
('new-b', 'h\n')],
list(my_plan.plan_merge()))
More information about the bazaar-commits
mailing list