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