~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revisionspec.py

  • Committer: Robert Collins
  • Date: 2007-11-22 00:33:15 UTC
  • mto: This revision was merged to the branch mainline in revision 3014.
  • Revision ID: robertc@robertcollins.net-20071122003315-ldoyi2mi3nma5qnf
Lock branches while doing revision specification lookups.

Show diffs side-by-side

added added

removed removed

Lines of Context:
639
639
        for r, b in ((revision_a, branch), (revision_b, other_branch)):
640
640
            if r in (None, revision.NULL_REVISION):
641
641
                raise errors.NoCommits(b)
642
 
        revision_source = revision.MultipleRevisionSources(
643
 
                branch.repository, other_branch.repository)
644
 
        graph = branch.repository.get_graph(other_branch.repository)
645
 
        revision_a = revision.ensure_null(revision_a)
646
 
        revision_b = revision.ensure_null(revision_b)
647
 
        if revision.NULL_REVISION in (revision_a, revision_b):
648
 
            rev_id = revision.NULL_REVISION
649
 
        else:
650
 
            rev_id = graph.find_unique_lca(revision_a, revision_b)
651
 
            if rev_id == revision.NULL_REVISION:
652
 
                raise errors.NoCommonAncestor(revision_a, revision_b)
 
642
        branch.lock_read()
 
643
        other_branch.lock_read()
653
644
        try:
654
 
            revno = branch.revision_id_to_revno(rev_id)
655
 
        except errors.NoSuchRevision:
656
 
            revno = None
657
 
        return RevisionInfo(branch, revno, rev_id)
 
645
            revision_source = revision.MultipleRevisionSources(
 
646
                    branch.repository, other_branch.repository)
 
647
            graph = branch.repository.get_graph(other_branch.repository)
 
648
            revision_a = revision.ensure_null(revision_a)
 
649
            revision_b = revision.ensure_null(revision_b)
 
650
            if revision.NULL_REVISION in (revision_a, revision_b):
 
651
                rev_id = revision.NULL_REVISION
 
652
            else:
 
653
                rev_id = graph.find_unique_lca(revision_a, revision_b)
 
654
                if rev_id == revision.NULL_REVISION:
 
655
                    raise errors.NoCommonAncestor(revision_a, revision_b)
 
656
            try:
 
657
                revno = branch.revision_id_to_revno(rev_id)
 
658
            except errors.NoSuchRevision:
 
659
                revno = None
 
660
            return RevisionInfo(branch, revno, rev_id)
 
661
        finally:
 
662
            branch.unlock()
 
663
            other_branch.unlock()
658
664
 
659
665
 
660
666
SPEC_TYPES.append(RevisionSpec_ancestor)