Rev 3510: Shortcut when one side dominates, though it would be better to do so earlier. in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/merge3_per_file
John Arbash Meinel
john at arbash-meinel.com
Sat Jun 21 02:43:11 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/merge3_per_file
------------------------------------------------------------
revno: 3510
revision-id: john at arbash-meinel.com-20080621014242-hq64iwxo0ldvayqy
parent: john at arbash-meinel.com-20080621012108-gd43ci897wohmgj1
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: merge3_per_file
timestamp: Fri 2008-06-20 20:42:42 -0500
message:
Shortcut when one side dominates, though it would be better to do so earlier.
-------------- next part --------------
=== modified file 'bzrlib/merge.py'
--- a/bzrlib/merge.py 2008-06-21 01:21:08 +0000
+++ b/bzrlib/merge.py 2008-06-21 01:42:42 +0000
@@ -1380,16 +1380,30 @@
self.a_rev = a_rev
self.b_rev = b_rev
self.vf = vf
- self._build_weave()
+ self.graph = _mod_graph.Graph(self.vf)
+ heads = self.graph.heads((a_rev, b_rev))
+ 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 = heads.pop()
+ if self._head == a_rev:
+ other = b_rev
+ else:
+ other = a_rev
+ note('found dominating revision for %s\n%s > %s', self.vf,
+ self._head, other)
+ else:
+ self._head = None
+ self._build_weave()
def _find_recursive_lcas(self):
"""Find all the ancestors back to a unique lca"""
cur_ancestors = (self.a_rev, self.b_rev)
note('finding lcas for %s:\n%s', self.vf, cur_ancestors)
- graph = _mod_graph.Graph(self.vf)
ancestors = [cur_ancestors]
while True:
- next_lcas = graph.find_lca(*cur_ancestors)
+ next_lcas = self.graph.find_lca(*cur_ancestors)
ancestors.append(next_lcas)
if len(next_lcas) == 0:
ancestors[-1] = (NULL_REVISION,)
@@ -1443,6 +1457,14 @@
are combined, they are written out in the format described in
VersionedFile.plan_merge
"""
+ if self._head is not None: # There was a single head
+ if self._head == self.a_rev:
+ plan = 'new-a'
+ else:
+ assert self._head == self.b_rev
+ plan = 'new-b'
+ lines = self.vf.get_lines(self._head)
+ return ((plan, line) for line in lines)
return self._weave.plan_merge(self.a_rev, self.b_rev)
More information about the bazaar-commits
mailing list