802
802
pb = bzrlib.ui.ui_factory.progress_bar()
803
803
pb.update('comparing histories')
804
if stop_revision is None:
805
other_revision = other.last_patch()
807
other_revision = other.lookup_revision(stop_revision)
808
count = greedy_fetch(self, other, other_revision, pb)[0]
806
810
revision_ids = self.missing_revisions(other, stop_revision)
807
811
except DivergedBranches, e:
809
if stop_revision is None:
810
end_revision = other.last_patch()
811
813
revision_ids = get_intervening_revisions(self.last_patch(),
814
other_revision, self)
813
815
assert self.last_patch() not in revision_ids
814
816
except bzrlib.errors.NotAncestor:
817
if len(revision_ids) > 0:
818
count = greedy_fetch(self, other, revision_ids[-1], pb)[0]
821
819
self.append_revision(*revision_ids)
822
## note("Added %d revisions." % count)
825
822
def install_revisions(self, other, revision_ids, pb):
826
823
if hasattr(other.revision_store, "prefetch"):
827
824
other.revision_store.prefetch(revision_ids)
828
825
if hasattr(other.inventory_store, "prefetch"):
829
inventory_ids = [other.get_revision(r).inventory_id
830
for r in revision_ids]
827
for rev_id in revision_ids:
829
revision = other.get_revision(rev_id).inventory_id
830
inventory_ids.append(revision)
831
except bzrlib.errors.NoSuchRevision:
831
833
other.inventory_store.prefetch(inventory_ids)
1082
1084
REVISION_NAMESPACES['date:'] = _namespace_date
1087
def _namespace_ancestor(self, revs, revision):
1088
from revision import common_ancestor, MultipleRevisionSources
1089
other_branch = find_branch(_trim_namespace('ancestor', revision))
1090
revision_a = self.last_patch()
1091
revision_b = other_branch.last_patch()
1092
for r, b in ((revision_a, self), (revision_b, other_branch)):
1094
raise bzrlib.errors.NoCommits(b)
1095
revision_source = MultipleRevisionSources(self, other_branch)
1096
result = common_ancestor(revision_a, revision_b, revision_source)
1098
revno = self.revision_id_to_revno(result)
1099
except bzrlib.errors.NoSuchRevision:
1104
REVISION_NAMESPACES['ancestor:'] = _namespace_ancestor
1084
1106
def revision_tree(self, revision_id):
1085
1107
"""Return Tree for a revision on this branch.
1518
1540
br_to.update_revisions(branch_from, stop_revision=revno)
1519
1541
merge((to_location, -1), (to_location, 0), this_dir=to_location,
1520
1542
check_clean=False, ignore_zero=True)
1522
1543
br_to.set_parent(branch_from.base)
1546
def _trim_namespace(namespace, spec):
1547
full_namespace = namespace + ':'
1548
assert spec.startswith(full_namespace)
1549
return spec[len(full_namespace):]