820
821
def update_revisions(self, other, stop_revision=None):
821
822
"""Pull in all new revisions from other branch.
823
>>> from bzrlib.commit import commit
824
>>> bzrlib.trace.silent = True
825
>>> br1 = ScratchBranch(files=['foo', 'bar'])
828
>>> commit(br1, "lala!", rev_id="REVISION-ID-1", verbose=False)
829
>>> br2 = ScratchBranch()
830
>>> br2.update_revisions(br1)
834
>>> br2.revision_history()
836
>>> br2.update_revisions(br1)
840
>>> br1.text_store.total_size() == br2.text_store.total_size()
843
progress = bzrlib.ui.ui_factory.progress_bar()
844
progress.update('comparing histories')
824
from bzrlib.fetch import greedy_fetch
826
pb = bzrlib.ui.ui_factory.progress_bar()
827
pb.update('comparing histories')
845
829
revision_ids = self.missing_revisions(other, stop_revision)
846
count = self.install_revisions(other, revision_ids, progress=progress)
831
if len(revision_ids) > 0:
832
count = greedy_fetch(self, other, revision_ids[-1], pb)[0]
847
835
self.append_revision(*revision_ids)
848
print "Added %d revisions." % count
836
## note("Added %d revisions." % count)
851
def install_revisions(self, other, revision_ids, progress=None):
839
def install_revisions(self, other, revision_ids, pb):
852
840
if hasattr(other.revision_store, "prefetch"):
853
841
other.revision_store.prefetch(revision_ids)
854
842
if hasattr(other.inventory_store, "prefetch"):
855
843
inventory_ids = [other.get_revision(r).inventory_id
856
844
for r in revision_ids]
857
845
other.inventory_store.prefetch(inventory_ids)
848
pb = bzrlib.ui.ui_factory.progress_bar()
860
851
needed_texts = set()
862
for rev_id in revision_ids:
865
progress.update('fetching revision', i, len(revision_ids))
866
rev = other.get_revision(rev_id)
855
for i, rev_id in enumerate(revision_ids):
856
pb.update('fetching revision', i+1, len(revision_ids))
858
rev = other.get_revision(rev_id)
859
except bzrlib.errors.NoSuchRevision:
867
863
revisions.append(rev)
868
864
inv = other.get_inventory(str(rev.inventory_id))
869
865
for key, entry in inv.iter_entries():
872
868
if entry.text_id not in self.text_store:
873
869
needed_texts.add(entry.text_id)
878
count = self.text_store.copy_multi(other.text_store, needed_texts)
873
count, cp_fail = self.text_store.copy_multi(other.text_store,
879
875
print "Added %d texts." % count
880
876
inventory_ids = [ f.inventory_id for f in revisions ]
881
count = self.inventory_store.copy_multi(other.inventory_store,
877
count, cp_fail = self.inventory_store.copy_multi(other.inventory_store,
883
879
print "Added %d inventories." % count
884
880
revision_ids = [ f.revision_id for f in revisions]
885
count = self.revision_store.copy_multi(other.revision_store,
882
count, cp_fail = self.revision_store.copy_multi(other.revision_store,
885
assert len(cp_fail) == 0
886
return count, failures
889
889
def commit(self, *args, **kw):
890
890
from bzrlib.commit import commit
891
891
commit(self, *args, **kw)