Rev 2402: Shortcut the common_ancestor code when one tip is in the ancestry of the other. in http://bzr.arbash-meinel.com/branches/bzr/0.16-dev/shortcut-common-ancestor
John Arbash Meinel
john at arbash-meinel.com
Tue Apr 10 18:57:38 BST 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.16-dev/shortcut-common-ancestor
------------------------------------------------------------
revno: 2402
revision-id: john at arbash-meinel.com-20070410175723-9a3rljph39ot4e35
parent: pqm at pqm.ubuntu.com-20070405073143-8fa894c829ab5e50
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: shortcut-common-ancestor
timestamp: Tue 2007-04-10 12:57:23 -0500
message:
Shortcut the common_ancestor code when one tip is in the ancestry of the other.
modified:
bzrlib/revision.py revision.py-20050309040759-e77802c08f3999d5
-------------- next part --------------
=== modified file 'bzrlib/revision.py'
--- a/bzrlib/revision.py 2007-01-17 15:37:08 +0000
+++ b/bzrlib/revision.py 2007-04-10 17:57:23 +0000
@@ -251,11 +251,18 @@
pb.update('Picking ancestor', 1, 3)
graph = revision_source.get_revision_graph_with_ghosts(
[revision_a, revision_b])
+ # Shortcut the case where one of the tips is already included in
+ # the other graphs ancestry.
+ ancestry_a = set(graph.get_ancestry(revision_a))
+ ancestry_b = set(graph.get_ancestry(revision_b))
+ if revision_b in ancestry_a:
+ return revision_b
+ if revision_a in ancestry_b:
+ return revision_a
# convert to a NULL_REVISION based graph.
ancestors = graph.get_ancestors()
descendants = graph.get_descendants()
- common = set(graph.get_ancestry(revision_a)).intersection(
- set(graph.get_ancestry(revision_b)))
+ common = ancestry_a.intersection(ancestry_b)
descendants[NULL_REVISION] = {}
ancestors[NULL_REVISION] = []
for root in graph.roots:
More information about the bazaar-commits
mailing list