~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: aaron.bentley at utoronto
  • Date: 2005-08-21 00:08:08 UTC
  • mto: (1092.1.41) (1185.3.4)
  • mto: This revision was merged to the branch mainline in revision 1110.
  • Revision ID: aaron.bentley@utoronto.ca-20050821000808-2a0e6ef95b1bca59
Changed copy_multi to permit failure and return a tuple, tested missing required revisions

Show diffs side-by-side

added added

removed removed

Lines of Context:
838
838
        pb = ProgressBar()
839
839
        pb.update('comparing histories')
840
840
        revision_ids = self.missing_revisions(other, stop_revision)
841
 
        count = self.install_revisions(other, revision_ids, pb=pb)
 
841
        count, failures = self.install_revisions(other, revision_ids, pb=pb)
842
842
        self.append_revision(*revision_ids)
843
843
        print "Added %d revisions." % count
 
844
        assert len(failures) == 0
844
845
                    
845
846
    def install_revisions(self, other, revision_ids, pb=None):
846
847
        if pb is None:
855
856
        revisions = []
856
857
        needed_texts = set()
857
858
        i = 0
858
 
        for rev_id in revision_ids:
859
 
            i += 1
860
 
            pb.update('fetching revision', i, len(revision_ids))
861
 
            rev = other.get_revision(rev_id)
 
859
        failures = set()
 
860
        for i, rev_id in enumerate(revision_ids):
 
861
            pb.update('fetching revision', i+1, len(revision_ids))
 
862
            try:
 
863
                rev = other.get_revision(rev_id)
 
864
            except bzrlib.errors.NoSuchRevision:
 
865
                failures.add(rev_id)
 
866
                continue
862
867
            revisions.append(rev)
863
868
            inv = other.get_inventory(str(rev.inventory_id))
864
869
            for key, entry in inv.iter_entries():
869
874
 
870
875
        pb.clear()
871
876
                    
872
 
        count = self.text_store.copy_multi(other.text_store, needed_texts)
 
877
        count, cp_fail = self.text_store.copy_multi(other.text_store, 
 
878
                                                    needed_texts)
873
879
        print "Added %d texts." % count 
874
880
        inventory_ids = [ f.inventory_id for f in revisions ]
875
 
        count = self.inventory_store.copy_multi(other.inventory_store, 
876
 
                                                inventory_ids)
 
881
        count, cp_fail = self.inventory_store.copy_multi(other.inventory_store, 
 
882
                                                         inventory_ids)
877
883
        print "Added %d inventories." % count 
878
884
        revision_ids = [ f.revision_id for f in revisions]
879
 
        count = self.revision_store.copy_multi(other.revision_store, 
880
 
                                               revision_ids)
881
 
        return count
 
885
        count, cp_fail = self.revision_store.copy_multi(other.revision_store, 
 
886
                                                          revision_ids,
 
887
                                                          permit_failure=True)
 
888
        assert len(cp_fail) == 0 
 
889
        return count, failures
882
890
       
883
891
    def commit(self, *args, **kw):
884
892
        from bzrlib.commit import commit