~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: abentley
  • Date: 2005-10-16 23:47:26 UTC
  • mto: (1185.25.1)
  • mto: This revision was merged to the branch mainline in revision 1460.
  • Revision ID: abentley@lappy-20051016234726-c7699fd0b77457d2
Restored branch convergence to bzr pull

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
                           DivergedBranches, LockError, UnlistableStore,
36
36
                           UnlistableBranch, NoSuchFile)
37
37
from bzrlib.textui import show_status
38
 
from bzrlib.revision import Revision
 
38
from bzrlib.revision import Revision, is_ancestor, get_intervening_revisions
 
39
 
39
40
from bzrlib.delta import compare_trees
40
41
from bzrlib.tree import EmptyTree, RevisionTree
41
42
from bzrlib.inventory import Inventory
952
953
        # revision in this branch is completely merged into the other,
953
954
        # then we should still be able to pull.
954
955
        from bzrlib.fetch import greedy_fetch
955
 
        from bzrlib.revision import get_intervening_revisions
956
956
        if stop_revision is None:
957
957
            stop_revision = other.last_revision()
 
958
        ### Should this be checking is_ancestor instead of revision_history?
958
959
        if (stop_revision is not None and 
959
960
            stop_revision in self.revision_history()):
960
961
            return
961
962
        greedy_fetch(to_branch=self, from_branch=other,
962
963
                     revision=stop_revision)
963
 
        pullable_revs = self.missing_revisions(
964
 
            other, other.revision_id_to_revno(stop_revision))
 
964
        pullable_revs = self.pullable_revisions(other, stop_revision)
965
965
        if pullable_revs:
966
966
            greedy_fetch(to_branch=self,
967
967
                         from_branch=other,
968
968
                         revision=pullable_revs[-1])
969
969
            self.append_revision(*pullable_revs)
970
 
    
 
970
 
 
971
    def pullable_revisions(self, other, stop_revision):
 
972
        other_revno = other.revision_id_to_revno(stop_revision)
 
973
        try:
 
974
            return self.missing_revisions(other, other_revno)
 
975
        except DivergedBranches, e:
 
976
            try:
 
977
                pullable_revs = get_intervening_revisions(self.last_revision(),
 
978
                                                          stop_revision, self)
 
979
                assert self.last_revision() not in pullable_revs
 
980
                return pullable_revs
 
981
            except bzrlib.errors.NotAncestor:
 
982
                if is_ancestor(self.last_revision(), stop_revision, self):
 
983
                    return []
 
984
                else:
 
985
                    raise e
 
986
        
971
987
 
972
988
    def commit(self, *args, **kw):
973
989
        from bzrlib.commit import Commit