~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-02-01 23:48:08 UTC
  • mfrom: (2225.1.6 revert)
  • Revision ID: pqm@pqm.ubuntu.com-20070201234808-3b1302d73474bd8c
Display changes made by revert

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
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
class Revision(object):
32
34
    """Single revision on a branch.
117
119
    revisions_source is an object supporting a get_revision operation that
118
120
    behaves like Branch's.
119
121
    """
120
 
    return candidate_id in branch.repository.get_ancestry(revision_id)
 
122
    return (candidate_id in branch.repository.get_ancestry(revision_id))
121
123
 
122
124
 
123
125
def iter_ancestors(revision_id, revision_source, only_present=False):
153
155
    anc_iter = enumerate(iter_ancestors(revision_id, revision_source,
154
156
                         only_present=True))
155
157
    for anc_order, (anc_id, anc_distance) in anc_iter:
156
 
        if not found_ancestors.has_key(anc_id):
 
158
        if anc_id not in found_ancestors:
157
159
            found_ancestors[anc_id] = (anc_order, anc_distance)
158
160
    return found_ancestors
159
161
    
452
454
        next = best_ancestor(next)
453
455
    path.reverse()
454
456
    return path
 
457
 
 
458
 
 
459
def is_reserved_id(revision_id):
 
460
    """Determine whether a revision id is reserved
 
461
 
 
462
    :return: True if the revision is is reserved, False otherwise
 
463
    """
 
464
    return isinstance(revision_id, basestring) and revision_id.endswith(':')
 
465
 
 
466
 
 
467
def check_not_reserved_id(revision_id):
 
468
    """Raise ReservedId if the supplied revision_id is reserved"""
 
469
    if is_reserved_id(revision_id):
 
470
        raise errors.ReservedId(revision_id)