~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revisionspec.py

  • Committer: John Arbash Meinel
  • Date: 2007-03-22 19:54:30 UTC
  • mfrom: (2371 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2373.
  • Revision ID: john@arbash-meinel.com-20070322195430-wi92c7jpx17kiagr
[merge] bzr.dev 2371

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from bzrlib import (
23
23
    errors,
 
24
    osutils,
24
25
    revision,
25
26
    symbol_versioning,
26
27
    trace,
379
380
    prefix = 'revid:'
380
381
 
381
382
    def _match_on(self, branch, revs):
382
 
        return RevisionInfo.from_revision_id(branch, self.spec, revs)
 
383
        # self.spec comes straight from parsing the command line arguments,
 
384
        # so we expect it to be a Unicode string. Switch it to the internal
 
385
        # representation.
 
386
        revision_id = osutils.safe_revision_id(self.spec, warn=False)
 
387
        return RevisionInfo.from_revision_id(branch, revision_id, revs)
383
388
 
384
389
SPEC_TYPES.append(RevisionSpec_revid)
385
390
 
477
482
 
478
483
    help_txt = """Selects a revision identified by a tag name.
479
484
 
480
 
    Tags are stored in the repository and created by the 'tag'
481
 
    command.
 
485
    Tags are stored in the branch and created by the 'tag' command.
482
486
    """
483
487
 
484
488
    prefix = 'tag:'
619
623
    prefix = 'ancestor:'
620
624
 
621
625
    def _match_on(self, branch, revs):
 
626
        trace.mutter('matching ancestor: on: %s, %s', self.spec, branch)
 
627
        return self._find_revision_info(branch, self.spec)
 
628
 
 
629
    @staticmethod
 
630
    def _find_revision_info(branch, other_location):
622
631
        from bzrlib.branch import Branch
623
632
 
624
 
        trace.mutter('matching ancestor: on: %s, %s', self.spec, branch)
625
 
        other_branch = Branch.open(self.spec)
 
633
        other_branch = Branch.open(other_location)
626
634
        revision_a = branch.last_revision()
627
635
        revision_b = other_branch.last_revision()
628
636
        for r, b in ((revision_a, branch), (revision_b, other_branch)):
637
645
        except errors.NoSuchRevision:
638
646
            revno = None
639
647
        return RevisionInfo(branch, revno, rev_id)
640
 
        
 
648
 
 
649
 
641
650
SPEC_TYPES.append(RevisionSpec_ancestor)
642
651
 
643
652
 
668
677
        return RevisionInfo(branch, revno, revision_b)
669
678
        
670
679
SPEC_TYPES.append(RevisionSpec_branch)
 
680
 
 
681
 
 
682
class RevisionSpec_submit(RevisionSpec_ancestor):
 
683
    """Selects a common ancestor with a submit branch."""
 
684
 
 
685
    help_txt = """Selects a common ancestor with the submit branch.
 
686
 
 
687
    Diffing against this shows all the changes that were made in this branch,
 
688
    and is a good predictor of what merge will do.  The submit branch is
 
689
    used by the bundle and merge directive comands.  If no submit branch
 
690
    is specified, the parent branch is used instead.
 
691
 
 
692
    The common ancestor is the last revision that existed in both
 
693
    branches. Usually this is the branch point, but it could also be
 
694
    a revision that was merged.
 
695
 
 
696
    examples:
 
697
      $ bzr diff -r submit:
 
698
    """
 
699
 
 
700
    prefix = 'submit:'
 
701
 
 
702
    def _match_on(self, branch, revs):
 
703
        trace.mutter('matching ancestor: on: %s, %s', self.spec, branch)
 
704
        submit_location = branch.get_submit_branch()
 
705
        location_type = 'submit branch'
 
706
        if submit_location is None:
 
707
            submit_location = branch.get_parent()
 
708
            location_type = 'parent branch'
 
709
        if submit_location is None:
 
710
            raise errors.NoSubmitBranch(branch)
 
711
        trace.note('Using %s %s', location_type, submit_location)
 
712
        return self._find_revision_info(branch, submit_location)
 
713
 
 
714
 
 
715
SPEC_TYPES.append(RevisionSpec_submit)