334
334
raise NotImplementedError('update_revisions is abstract')
336
def pullable_revisions(self, other, stop_revision):
337
raise NotImplementedError('pullable_revisions is abstract')
339
336
def revision_id_to_revno(self, revision_id):
340
337
"""Given a revision id, return its revno"""
341
338
if revision_id is None:
1016
1013
# transaction.register_clean(history, precious=True)
1017
1014
return list(history)
1019
1017
def update_revisions(self, other, stop_revision=None):
1020
1018
"""See Branch.update_revisions."""
1021
if stop_revision is None:
1022
stop_revision = other.last_revision()
1023
### Should this be checking is_ancestor instead of revision_history?
1024
if (stop_revision is not None and
1025
stop_revision in self.revision_history()):
1027
self.fetch(other, stop_revision)
1028
pullable_revs = self.pullable_revisions(other, stop_revision)
1029
if len(pullable_revs) > 0:
1030
self.append_revision(*pullable_revs)
1021
if stop_revision is None:
1022
stop_revision = other.last_revision()
1023
if stop_revision is None:
1024
# if there are no commits, we're done.
1026
# whats the current last revision, before we fetch [and change it
1028
last_rev = self.last_revision()
1029
# we fetch here regardless of whether we need to so that we pickup
1031
self.fetch(other, stop_revision)
1032
my_ancestry = self.repository.get_ancestry(last_rev)
1033
if stop_revision in my_ancestry:
1034
# last_revision is a descendant of stop_revision
1036
# stop_revision must be a descendant of last_revision
1037
stop_graph = self.repository.get_revision_graph(stop_revision)
1038
if last_rev is not None and last_rev not in stop_graph:
1039
# our previous tip is not merged into stop_revision
1040
raise errors.DivergedBranches(self, other)
1041
# make a new revision history from the graph
1042
current_rev_id = stop_revision
1044
while current_rev_id not in (None, NULL_REVISION):
1045
new_history.append(current_rev_id)
1046
current_rev_id_parents = stop_graph[current_rev_id]
1048
current_rev_id = current_rev_id_parents[0]
1050
current_rev_id = None
1051
new_history.reverse()
1052
self.set_revision_history(new_history)
1056
@deprecated_method(zero_eight)
1032
1057
def pullable_revisions(self, other, stop_revision):
1058
"""Please use bzrlib.missing instead."""
1033
1059
other_revno = other.revision_id_to_revno(stop_revision)
1035
1061
return self.missing_revisions(other, other_revno)