~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revisionspec.py

  • Committer: Robert Collins
  • Date: 2005-10-10 01:32:08 UTC
  • Revision ID: robertc@robertcollins.net-20051010013208-163c23746972763a
branch: namespace

Show diffs side-by-side

added added

removed removed

Lines of Context:
151
151
        revs = branch.revision_history()
152
152
        return self._match_on_and_check(branch, revs)
153
153
 
 
154
        # FIXME: in_history is somewhat broken,
 
155
        # it will return non-history revisions in many
 
156
        # circumstances. The expected facility is that
 
157
        # in_history only returns revision-history revs,
 
158
        # in_store returns any rev. RBC 20051010
 
159
    # aliases for now, when we fix the core logic, then they
 
160
    # will do what you expect.
 
161
    in_store = in_history
 
162
    in_branch = in_store
 
163
        
154
164
    def __repr__(self):
155
165
        # this is mostly for helping with testing
156
166
        return '<%s %s%s>' % (self.__class__.__name__,
318
328
        return RevisionInfo(branch, revno, rev_id)
319
329
        
320
330
SPEC_TYPES.append(RevisionSpec_ancestor)
 
331
 
 
332
class RevisionSpec_branch(RevisionSpec):
 
333
    """A branch: revision specifier.
 
334
 
 
335
    This takes the path to a branch and returns its tip revision id.
 
336
    """
 
337
    prefix = 'branch:'
 
338
 
 
339
    def _match_on(self, branch, revs):
 
340
        from branch import Branch
 
341
        from fetch import greedy_fetch
 
342
        other_branch = Branch.open_containing(self.spec)
 
343
        revision_b = other_branch.last_revision()
 
344
        if revision_b is None:
 
345
            raise NoCommits(other_branch)
 
346
        # pull in the remote revisions so we can diff
 
347
        greedy_fetch(branch, other_branch, revision=revision_b)
 
348
        try:
 
349
            revno = branch.revision_id_to_revno(revision_b)
 
350
        except NoSuchRevision:
 
351
            revno = None
 
352
        return RevisionInfo(branch, revno, revision_b)
 
353
        
 
354
SPEC_TYPES.append(RevisionSpec_branch)