~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Martin Pool
  • Date: 2006-02-22 04:29:54 UTC
  • mfrom: (1566 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1569.
  • Revision ID: mbp@sourcefrog.net-20060222042954-60333f08dd56a646
[merge] from bzr.dev before integration
Fix undefined ordering in sign_my_revisions breaking tests

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
 
78
79
                raise ValueError("invalid property value %r for %r" % 
79
80
                                 (name, value))
80
81
 
 
82
    def get_history(self, repository):
 
83
        """Return the canonical line-of-history for this revision.
 
84
 
 
85
        If ghosts are present this may differ in result from a ghost-free
 
86
        repository.
 
87
        """
 
88
        current_revision = self
 
89
        reversed_result = []
 
90
        while current_revision is not None:
 
91
            reversed_result.append(current_revision.revision_id)
 
92
            if not len (current_revision.parent_ids):
 
93
                reversed_result.append(None)
 
94
                current_revision = None
 
95
            else:
 
96
                next_revision_id = current_revision.parent_ids[0]
 
97
                current_revision = repository.get_revision(next_revision_id)
 
98
        reversed_result.reverse()
 
99
        return reversed_result
 
100
 
81
101
 
82
102
def is_ancestor(revision_id, candidate_id, branch):
83
103
    """Return true if candidate_id is an ancestor of revision_id.
260
280
    return root, ancestors, descendants, common
261
281
 
262
282
 
263
 
def common_ancestor(revision_a, revision_b, revision_source):
 
283
def common_ancestor(revision_a, revision_b, revision_source, 
 
284
                    pb=DummyProgress()):
264
285
    try:
265
 
        root, ancestors, descendants, common = \
266
 
            combined_graph(revision_a, revision_b, revision_source)
267
 
    except bzrlib.errors.NoCommonRoot:
268
 
        raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
269
 
        
270
 
    distances = node_distances (descendants, ancestors, root)
271
 
    farthest = select_farthest(distances, common)
272
 
    if farthest is None or farthest == NULL_REVISION:
273
 
        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()
274
301
    return farthest
275
302
 
276
303