~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revisionspec.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-21 23:50:08 UTC
  • mto: This revision was merged to the branch mainline in revision 1979.
  • Revision ID: john@arbash-meinel.com-20060821235008-6730d6958c745fe9
Going before:0 is an error, and if you are on another history, use the leftmost parent

Show diffs side-by-side

added added

removed removed

Lines of Context:
294
294
    
295
295
    def _match_on(self, branch, revs):
296
296
        r = RevisionSpec(self.spec)._match_on(branch, revs)
297
 
        if (r.revno is None) or (r.revno == 0):
298
 
            return r
299
 
        return RevisionInfo(branch, r.revno - 1)
 
297
        if r.revno == 0:
 
298
            raise errors.InvalidRevisionSpec(self.prefix + self.spec, branch,
 
299
                                         'cannot go before the null: revision')
 
300
        if r.revno is None:
 
301
            # We need to use the repository history here
 
302
            rev = branch.repository.get_revision(r.rev_id)
 
303
            if not rev.parent_ids:
 
304
                revno = 0
 
305
                revision_id = None
 
306
            else:
 
307
                revision_id = rev.parent_ids[0]
 
308
                try:
 
309
                    revno = revs.index(revision_id) + 1
 
310
                except ValueError:
 
311
                    revno = None
 
312
        else:
 
313
            revno = r.revno - 1
 
314
            try:
 
315
                revision_id = branch.get_rev_id(revno, revs)
 
316
            except NoSuchRevision:
 
317
                raise errors.InvalidRevisionSpec(self.prefix + self.spec,
 
318
                                                 branch)
 
319
        return RevisionInfo(branch, revno, revision_id)
300
320
 
301
321
SPEC_TYPES.append(RevisionSpec_before)
302
322