~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-04-11 01:53:43 UTC
  • mfrom: (2401.1.5 shortcut-common-ancestor)
  • Revision ID: pqm@pqm.ubuntu.com-20070411015343-51539420298ee77c
(John Arbash Meinel) Fix bug #103757 by teaching common_ancestor to shortcut when a tip is in the other ancestry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
251
251
            pb.update('Picking ancestor', 1, 3)
252
252
            graph = revision_source.get_revision_graph_with_ghosts(
253
253
                [revision_a, revision_b])
 
254
            # Shortcut the case where one of the tips is already included in
 
255
            # the other graphs ancestry.
 
256
            ancestry_a = graph.get_ancestry(revision_a)
 
257
            if revision_b in ancestry_a:
 
258
                return revision_b
 
259
            ancestry_b = graph.get_ancestry(revision_b)
 
260
            if revision_a in ancestry_b:
 
261
                return revision_a
254
262
            # convert to a NULL_REVISION based graph.
255
263
            ancestors = graph.get_ancestors()
256
264
            descendants = graph.get_descendants()
257
 
            common = set(graph.get_ancestry(revision_a)).intersection(
258
 
                     set(graph.get_ancestry(revision_b)))
 
265
            common = set(ancestry_a)
 
266
            common.intersection_update(ancestry_b)
259
267
            descendants[NULL_REVISION] = {}
260
268
            ancestors[NULL_REVISION] = []
261
269
            for root in graph.roots: