/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/revision.py

  • Committer: Martin Pool
  • Date: 2005-07-04 11:57:18 UTC
  • Revision ID: mbp@sourcefrog.net-20050704115718-b532986c0714e7a7
- don't write precursor field in new revision xml
- make parents more primary; remove more precursor code
- test commit of revision with parents

Show diffs side-by-side

added added

removed removed

Lines of Context:
167
167
 
168
168
    if not REVISION_ID_RE.match(rid):
169
169
        raise ValueError("malformed revision-id %r" % rid)
170
 
 
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.
175
170
    
176
 
    revisions_source is an object supporting a get_revision operation that
177
 
    behaves like Branch's.
178
 
    """
179
 
 
180
 
    from bzrlib.branch import NoSuchRevision
181
 
    ancestors = (revision_id,)
182
 
    while len(ancestors) > 0:
183
 
        new_ancestors = []
184
 
        for ancestor in ancestors:
185
 
            if ancestor == candidate_id:
186
 
                return True
187
 
            try:
188
 
                revision = revision_source.get_revision(ancestor)
189
 
            except NoSuchRevision, e:
190
 
                if e.revision == revision_id:
191
 
                    raise e
192
 
                else:
193
 
                    continue
194
 
            new_ancestors.extend([p.revision_id for p in revision.parents])
195
 
        ancestors = new_ancestors
196
 
 
197
 
 
198
 
class MultipleRevisionSources(object):
199
 
    def __init__(self, *args):
200
 
        object.__init__(self)
201
 
        assert len(args) != 0
202
 
        self._revision_sources = args
203
 
 
204
 
    def get_revision(self, revision_id):
205
 
        from bzrlib.branch import NoSuchRevision
206
 
        for source in self._revision_sources:
207
 
            try:
208
 
                return source.get_revision(revision_id)
209
 
            except NoSuchRevision, e:
210
 
                pass
211
 
        raise e