668
668
return RevisionInfo(branch, revno, revision_b)
670
670
SPEC_TYPES.append(RevisionSpec_branch)
673
class RevisionSpec_ancestor(RevisionSpec):
674
"""Selects a common ancestor with a submit branch."""
676
help_txt = """Selects a common ancestor with the submit branch.
678
Diffing against this shows all the changes that were made in this branch,
679
and is a good predictor of what merge will do. The submit branch is
680
used by the bundle and merge directive comands. If no submit branch
681
is specified, the parent branch is used instead.
683
The common ancestor is the last revision that existed in both
684
branches. Usually this is the branch point, but it could also be
685
a revision that was merged.
688
$ bzr diff -r submit:
692
def _match_on(self, branch, revs):
693
from bzrlib.branch import Branch
695
trace.mutter('matching ancestor: on: %s, %s', self.spec, branch)
696
submit_location = branch.get_submit_branch()
697
if submit_location is None:
698
submit_location = branch.get_parent()
699
if submit_location is None:
700
raise errors.NoSubmitBranch(branch)
703
other_branch = Branch.open(submit_location)
704
revision_a = branch.last_revision()
705
revision_b = other_branch.last_revision()
706
for r, b in ((revision_a, branch), (revision_b, other_branch)):
707
if r in (None, revision.NULL_REVISION):
708
raise errors.NoCommits(b)
709
revision_source = revision.MultipleRevisionSources(
710
branch.repository, other_branch.repository)
711
rev_id = revision.common_ancestor(revision_a, revision_b,
714
revno = branch.revision_id_to_revno(rev_id)
715
except errors.NoSuchRevision:
717
return RevisionInfo(branch, revno, rev_id)
719
SPEC_TYPES.append(RevisionSpec_ancestor)