~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

MergeĀ mainline.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import bzrlib.errors
21
21
from bzrlib.graph import node_distances, select_farthest, all_descendants
22
22
from bzrlib.osutils import contains_whitespace
 
23
from bzrlib.progress import DummyProgress
23
24
 
24
25
NULL_REVISION="null:"
25
26
 
279
280
    return root, ancestors, descendants, common
280
281
 
281
282
 
282
 
def common_ancestor(revision_a, revision_b, revision_source):
 
283
def common_ancestor(revision_a, revision_b, revision_source, 
 
284
                    pb=DummyProgress()):
283
285
    try:
284
 
        root, ancestors, descendants, common = \
285
 
            combined_graph(revision_a, revision_b, revision_source)
286
 
    except bzrlib.errors.NoCommonRoot:
287
 
        raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
288
 
        
289
 
    distances = node_distances (descendants, ancestors, root)
290
 
    farthest = select_farthest(distances, common)
291
 
    if farthest is None or farthest == NULL_REVISION:
292
 
        raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
 
286
        try:
 
287
            pb.update('Picking ancestor', 1, 3)
 
288
            root, ancestors, descendants, common = \
 
289
                combined_graph(revision_a, revision_b, revision_source)
 
290
        except bzrlib.errors.NoCommonRoot:
 
291
            raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
 
292
            
 
293
        pb.update('Picking ancestor', 2, 3)
 
294
        distances = node_distances (descendants, ancestors, root)
 
295
        pb.update('Picking ancestor', 3, 2)
 
296
        farthest = select_farthest(distances, common)
 
297
        if farthest is None or farthest == NULL_REVISION:
 
298
            raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
 
299
    finally:
 
300
        pb.clear()
293
301
    return farthest
294
302
 
295
303