~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Martin Pool
  • Date: 2005-09-16 04:47:12 UTC
  • Revision ID: mbp@sourcefrog.net-20050916044711-e5a7bfc6ead3800b
- is_ancestor now works by looking at the Branch's stored ancestry

- some tests related to this

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
    if not REVISION_ID_RE.match(rid):
99
99
        raise ValueError("malformed revision-id %r" % rid)
100
100
 
101
 
def is_ancestor(revision_id, candidate_id, revision_source):
 
101
 
 
102
def is_ancestor(revision_id, candidate_id, branch):
102
103
    """Return true if candidate_id is an ancestor of revision_id.
 
104
 
103
105
    A false negative will be returned if any intermediate descendent of
104
106
    candidate_id is not present in any of the revision_sources.
105
107
    
106
108
    revisions_source is an object supporting a get_revision operation that
107
109
    behaves like Branch's.
108
110
    """
 
111
    return candidate_id in branch.get_ancestry(revision_id)
109
112
 
110
 
    for ancestor_id, distance in iter_ancestors(revision_id, revision_source):
111
 
        if ancestor_id == candidate_id:
112
 
            return True
113
 
    return False
114
113
 
115
114
def iter_ancestors(revision_id, revision_source, only_present=False):
116
115
    ancestors = (revision_id,)