~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
27
27
        )
28
28
 
29
29
NULL_REVISION="null:"
30
 
CURRENT_REVISION="current:"
31
30
 
32
31
 
33
32
class Revision(object):
251
250
            pb.update('Picking ancestor', 1, 3)
252
251
            graph = revision_source.get_revision_graph_with_ghosts(
253
252
                [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
262
253
            # convert to a NULL_REVISION based graph.
263
254
            ancestors = graph.get_ancestors()
264
255
            descendants = graph.get_descendants()
265
 
            common = set(ancestry_a)
266
 
            common.intersection_update(ancestry_b)
 
256
            common = set(graph.get_ancestry(revision_a)).intersection(
 
257
                     set(graph.get_ancestry(revision_b)))
267
258
            descendants[NULL_REVISION] = {}
268
259
            ancestors[NULL_REVISION] = []
269
260
            for root in graph.roots:
462
453
        next = best_ancestor(next)
463
454
    path.reverse()
464
455
    return path
465
 
 
466
 
 
467
 
def is_reserved_id(revision_id):
468
 
    """Determine whether a revision id is reserved
469
 
 
470
 
    :return: True if the revision is is reserved, False otherwise
471
 
    """
472
 
    return isinstance(revision_id, basestring) and revision_id.endswith(':')
473
 
 
474
 
 
475
 
def check_not_reserved_id(revision_id):
476
 
    """Raise ReservedId if the supplied revision_id is reserved"""
477
 
    if is_reserved_id(revision_id):
478
 
        raise errors.ReservedId(revision_id)