805
805
"""Pull in all new revisions from other branch.
807
807
from bzrlib.fetch import greedy_fetch
808
from bzrlib.revision import get_intervening_revisions
810
809
pb = bzrlib.ui.ui_factory.progress_bar()
811
810
pb.update('comparing histories')
812
if stop_revision is None:
813
other_revision = other.last_patch()
812
revision_ids = self.missing_revisions(other, stop_revision)
814
if len(revision_ids) > 0:
815
count = greedy_fetch(self, other, revision_ids[-1], pb)[0]
815
other_revision = other.lookup_revision(stop_revision)
816
count = greedy_fetch(self, other, other_revision, pb)[0]
818
revision_ids = self.missing_revisions(other, stop_revision)
819
except DivergedBranches, e:
821
revision_ids = get_intervening_revisions(self.last_patch(),
822
other_revision, self)
823
assert self.last_patch() not in revision_ids
824
except bzrlib.errors.NotAncestor:
827
818
self.append_revision(*revision_ids)
819
## note("Added %d revisions." % count)
830
822
def install_revisions(self, other, revision_ids, pb):
831
823
if hasattr(other.revision_store, "prefetch"):
832
824
other.revision_store.prefetch(revision_ids)
833
825
if hasattr(other.inventory_store, "prefetch"):
835
for rev_id in revision_ids:
837
revision = other.get_revision(rev_id).inventory_id
838
inventory_ids.append(revision)
839
except bzrlib.errors.NoSuchRevision:
826
inventory_ids = [other.get_revision(r).inventory_id
827
for r in revision_ids]
841
828
other.inventory_store.prefetch(inventory_ids)
1092
1079
REVISION_NAMESPACES['date:'] = _namespace_date
1095
def _namespace_ancestor(self, revs, revision):
1096
from revision import common_ancestor, MultipleRevisionSources
1097
other_branch = find_branch(_trim_namespace('ancestor', revision))
1098
revision_a = self.last_patch()
1099
revision_b = other_branch.last_patch()
1100
for r, b in ((revision_a, self), (revision_b, other_branch)):
1102
raise bzrlib.errors.NoCommits(b)
1103
revision_source = MultipleRevisionSources(self, other_branch)
1104
result = common_ancestor(revision_a, revision_b, revision_source)
1106
revno = self.revision_id_to_revno(result)
1107
except bzrlib.errors.NoSuchRevision:
1112
REVISION_NAMESPACES['ancestor:'] = _namespace_ancestor
1114
1081
def revision_tree(self, revision_id):
1115
1082
"""Return Tree for a revision on this branch.
1562
1529
from_location = pull_loc(branch_from)
1563
1530
br_to.set_parent(pull_loc(branch_from))
1566
def _trim_namespace(namespace, spec):
1567
full_namespace = namespace + ':'
1568
assert spec.startswith(full_namespace)
1569
return spec[len(full_namespace):]