示例#1
0
    def _find_revision_id(branch, other_location):
        from bzrlib.branch import Branch

        branch.lock_read()
        try:
            revision_a = revision.ensure_null(branch.last_revision())
            if revision_a == revision.NULL_REVISION:
                raise errors.NoCommits(branch)
            if other_location == '':
                other_location = branch.get_parent()
            other_branch = Branch.open(other_location)
            other_branch.lock_read()
            try:
                revision_b = revision.ensure_null(other_branch.last_revision())
                if revision_b == revision.NULL_REVISION:
                    raise errors.NoCommits(other_branch)
                graph = branch.repository.get_graph(other_branch.repository)
                rev_id = graph.find_unique_lca(revision_a, revision_b)
            finally:
                other_branch.unlock()
            if rev_id == revision.NULL_REVISION:
                raise errors.NoCommonAncestor(revision_a, revision_b)
            return rev_id
        finally:
            branch.unlock()
示例#2
0
 def _as_tree(self, context_branch):
     from bzrlib.branch import Branch
     other_branch = Branch.open(self.spec)
     last_revision = other_branch.last_revision()
     last_revision = revision.ensure_null(last_revision)
     if last_revision == revision.NULL_REVISION:
         raise errors.NoCommits(other_branch)
     return other_branch.repository.revision_tree(last_revision)
示例#3
0
 def _as_revision_id(self, context_branch):
     from bzrlib.branch import Branch
     other_branch = Branch.open(self.spec)
     last_revision = other_branch.last_revision()
     last_revision = revision.ensure_null(last_revision)
     context_branch.fetch(other_branch, last_revision)
     if last_revision == revision.NULL_REVISION:
         raise errors.NoCommits(other_branch)
     return last_revision
示例#4
0
    def _revno_and_revision_id(self, context_branch):
        last_revno, last_revision_id = context_branch.last_revision_info()

        if self.spec == '':
            if not last_revno:
                raise errors.NoCommits(context_branch)
            return last_revno, last_revision_id

        try:
            offset = int(self.spec)
        except ValueError, e:
            raise errors.InvalidRevisionSpec(self.user_spec, context_branch, e)
示例#5
0
 def _match_on(self, branch, revs):
     from bzrlib.branch import Branch
     other_branch = Branch.open(self.spec)
     revision_b = other_branch.last_revision()
     if revision_b in (None, revision.NULL_REVISION):
         raise errors.NoCommits(other_branch)
     # pull in the remote revisions so we can diff
     branch.fetch(other_branch, revision_b)
     try:
         revno = branch.revision_id_to_revno(revision_b)
     except errors.NoSuchRevision:
         revno = None
     return RevisionInfo(branch, revno, revision_b)
示例#6
0
 def _match_on(self, branch, revs):
     from bzrlib.branch import Branch
     other_branch = Branch.open(self.spec)
     revision_b = other_branch.last_revision()
     if revision_b in (None, revision.NULL_REVISION):
         raise errors.NoCommits(other_branch)
     if branch is None:
         branch = other_branch
     else:
         try:
             # pull in the remote revisions so we can diff
             branch.fetch(other_branch, revision_b)
         except errors.ReadOnlyError:
             branch = other_branch
     return RevisionInfo(branch, None, revision_b)