~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Robert Collins
  • Date: 2005-08-24 06:53:07 UTC
  • mto: (974.1.50) (1185.1.10) (1092.3.1)
  • mto: This revision was merged to the branch mainline in revision 1139.
  • Revision ID: robertc@robertcollins.net-20050824065307-bca8ae89734a53f8
merge from mpool

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from bzrlib.osutils import isdir, quotefn, compact_date, rand_bytes, \
24
24
     splitpath, \
25
25
     sha_file, appendpath, file_kind
 
26
 
26
27
from bzrlib.errors import BzrError, InvalidRevisionNumber, InvalidRevisionId
27
28
import bzrlib.errors
28
29
from bzrlib.textui import show_status
30
31
from bzrlib.xml import unpack_xml
31
32
from bzrlib.delta import compare_trees
32
33
from bzrlib.tree import EmptyTree, RevisionTree
33
 
        
 
34
from bzrlib.progress import ProgressBar
 
35
 
34
36
BZR_BRANCH_FORMAT = "Bazaar-NG branch, format 0.0.4\n"
35
37
## TODO: Maybe include checks for common corruption of newlines, etc?
36
38
 
124
126
        head, tail = os.path.split(f)
125
127
        if head == f:
126
128
            # reached the root, whatever that may be
127
 
            raise bzrlib.errors.NotBranchError('%r is not in a branch' % orig_f)
 
129
            raise bzrlib.errors.NotBranchError('%s is not in a branch' % orig_f)
128
130
        f = head
129
131
 
130
132
 
770
772
            return None
771
773
 
772
774
 
773
 
    def missing_revisions(self, other, stop_revision=None):
 
775
    def missing_revisions(self, other, stop_revision=None, diverged_ok=False):
774
776
        """
775
777
        If self and other have not diverged, return a list of the revisions
776
778
        present in other, but missing from self.
809
811
        if stop_revision is None:
810
812
            stop_revision = other_len
811
813
        elif stop_revision > other_len:
812
 
            raise NoSuchRevision(self, stop_revision)
 
814
            raise bzrlib.errors.NoSuchRevision(self, stop_revision)
813
815
        
814
816
        return other_history[self_len:stop_revision]
815
817
 
837
839
        >>> br1.text_store.total_size() == br2.text_store.total_size()
838
840
        True
839
841
        """
840
 
        from bzrlib.progress import ProgressBar
841
 
 
842
842
        pb = ProgressBar()
843
 
 
844
843
        pb.update('comparing histories')
845
844
        revision_ids = self.missing_revisions(other, stop_revision)
846
 
 
 
845
        count = self.install_revisions(other, revision_ids, pb=pb)
 
846
        self.append_revision(*revision_ids)
 
847
        print "Added %d revisions." % count
 
848
                    
 
849
    def install_revisions(self, other, revision_ids, pb=None):
 
850
        if pb is None:
 
851
            pb = ProgressBar()
847
852
        if hasattr(other.revision_store, "prefetch"):
848
853
            other.revision_store.prefetch(revision_ids)
849
854
        if hasattr(other.inventory_store, "prefetch"):
877
882
        revision_ids = [ f.revision_id for f in revisions]
878
883
        count = self.revision_store.copy_multi(other.revision_store, 
879
884
                                               revision_ids)
880
 
        for revision_id in revision_ids:
881
 
            self.append_revision(revision_id)
882
 
        print "Added %d revisions." % count
883
 
                    
884
 
        
 
885
        return count
 
886
       
885
887
    def commit(self, *args, **kw):
886
888
        from bzrlib.commit import commit
887
889
        commit(self, *args, **kw)