168
168
if not REVISION_ID_RE.match(rid):
169
169
raise ValueError("malformed revision-id %r" % rid)
171
def is_ancestor(revision_id, candidate_id, revision_source):
172
"""Return true if candidate_id is an ancestor of revision_id.
173
A false negative will be returned if any intermediate descendent of
174
candidate_id is not present in any of the revision_sources.
176
revisions_source is an object supporting a get_revision operation that
177
behaves like Branch's.
180
from bzrlib.branch import NoSuchRevision
181
ancestors = (revision_id,)
182
while len(ancestors) > 0:
184
for ancestor in ancestors:
185
if ancestor == candidate_id:
188
revision = revision_source.get_revision(ancestor)
189
except NoSuchRevision, e:
190
if e.revision == revision_id:
194
new_ancestors.extend([p.revision_id for p in revision.parents])
195
ancestors = new_ancestors
198
class MultipleRevisionSources(object):
199
def __init__(self, *args):
200
object.__init__(self)
201
assert len(args) != 0
202
self._revision_sources = args
204
def get_revision(self, revision_id):
205
from bzrlib.branch import NoSuchRevision
206
for source in self._revision_sources:
208
return source.get_revision(revision_id)
209
except NoSuchRevision, e: