~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revisionspec.py

  • Committer: Lalo Martins
  • Date: 2005-09-15 15:16:12 UTC
  • mfrom: (1185.1.18)
  • mto: (1185.1.22)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: lalo@exoweb.net-20050915151611-86c5de4298bb71f9
merging from integration again.

This is a "checkpoint" commit; the tests don't actually pass, but all the
really hard stuff has been merged (in particular, Aaron's new ancestor:
namespace was moved to revisionspec).

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
import datetime
19
19
import re
20
 
from bzrlib.errors import BzrError, NoSuchRevision
 
20
from bzrlib.errors import BzrError, NoSuchRevision, NoCommits
21
21
 
22
22
_marker = []
23
23
 
49
49
            self.rev_id = rev_id
50
50
 
51
51
    def __nonzero__(self):
52
 
        return not (self.revno is None or self.rev_id is None)
 
52
        # first the easy ones...
 
53
        if self.rev_id is None:
 
54
            return False
 
55
        if self.revno is not None:
 
56
            return True
 
57
        # TODO: otherwise, it should depend on how I was built -
 
58
        # if it's in_history(branch), then check revision_history(),
 
59
        # if it's in_store(branch), do the check below
 
60
        return self.rev_id in self.branch.revision_store
53
61
 
54
62
    def __len__(self):
55
63
        return 2
301
309
                    return RevisionInfo(branch, i+1,)
302
310
 
303
311
SPEC_TYPES.append(RevisionSpec_date)
 
312
 
 
313
 
 
314
class RevisionSpec_ancestor(RevisionSpec):
 
315
    prefix = 'ancestor:'
 
316
 
 
317
    def _match_on(self, branch, revs):
 
318
        from branch import Branch
 
319
        from revision import common_ancestor, MultipleRevisionSources
 
320
        other_branch = Branch.open_containing(self.spec)
 
321
        revision_a = branch.last_patch()
 
322
        revision_b = other_branch.last_patch()
 
323
        for r, b in ((revision_a, branch), (revision_b, other_branch)):
 
324
            if r is None:
 
325
                raise NoCommits(b)
 
326
        revision_source = MultipleRevisionSources(branch, other_branch)
 
327
        rev_id = common_ancestor(revision_a, revision_b, revision_source)
 
328
        try:
 
329
            revno = branch.revision_id_to_revno(rev_id)
 
330
        except NoSuchRevision:
 
331
            revno = None
 
332
        return RevisionInfo(branch, revno, rev_id)
 
333
        
 
334
SPEC_TYPES.append(RevisionSpec_ancestor)