379
380
prefix = 'revid:'
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
386
revision_id = osutils.safe_revision_id(self.spec, warn=False)
387
return RevisionInfo.from_revision_id(branch, revision_id, revs)
384
389
SPEC_TYPES.append(RevisionSpec_revid)
619
623
prefix = 'ancestor:'
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)
630
def _find_revision_info(branch, other_location):
622
631
from bzrlib.branch import Branch
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)):
668
677
return RevisionInfo(branch, revno, revision_b)
670
679
SPEC_TYPES.append(RevisionSpec_branch)
682
class RevisionSpec_submit(RevisionSpec_ancestor):
683
"""Selects a common ancestor with a submit branch."""
685
help_txt = """Selects a common ancestor with the submit branch.
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.
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.
697
$ bzr diff -r submit:
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)
715
SPEC_TYPES.append(RevisionSpec_submit)