709
709
"""Synchronize last revision and revision history between branches.
711
711
This version is most efficient when the destination is also a
712
BzrBranch5, but works for BzrBranch6 as long as the revision
713
history is the true lefthand parent history, and all of the revisions
714
are in the destination's repository. If not, set_revision_history
712
BzrBranch6, but works for BzrBranch5, as long as the destination's
713
repository contains all the lefthand ancestors of the intended
714
last_revision. If not, set_last_revision_info will fail.
717
716
:param destination: The branch to copy the history into
718
717
:param revision_id: The revision-id to truncate history at. May
719
718
be None to copy complete history.
721
if revision_id == _mod_revision.NULL_REVISION:
720
source_revno, source_revision_id = self.last_revision_info()
721
if revision_id is None:
722
revno, revision_id = source_revno, source_revision_id
723
elif source_revision_id == revision_id:
724
# we know the revno without needing to walk all of history
724
new_history = self.revision_history()
725
if revision_id is not None and new_history != []:
727
new_history = new_history[:new_history.index(revision_id) + 1]
729
rev = self.repository.get_revision(revision_id)
730
new_history = rev.get_history(self.repository)[1:]
731
destination.set_revision_history(new_history)
727
# To figure out the revno for a random revision, we need to build
728
# the revision history, and count its length.
729
# We don't care about the order, just how long it is.
730
# Alternatively, we could start at the current location, and count
731
# backwards. But there is no guarantee that we will find it since
732
# it may be a merged revision.
733
revno = len(list(self.repository.iter_reverse_revision_history(
735
destination.set_last_revision_info(revno, revision_id)
734
738
def copy_content_into(self, destination, revision_id=None):
735
739
"""Copy the content of self into destination.
2252
2256
value = self.get_config().get_user_option('append_revisions_only')
2253
2257
return value == 'True'
2255
def _synchronize_history(self, destination, revision_id):
2256
"""Synchronize last revision and revision history between branches.
2258
This version is most efficient when the destination is also a
2259
BzrBranch6, but works for BzrBranch5, as long as the destination's
2260
repository contains all the lefthand ancestors of the intended
2261
last_revision. If not, set_last_revision_info will fail.
2263
:param destination: The branch to copy the history into
2264
:param revision_id: The revision-id to truncate history at. May
2265
be None to copy complete history.
2267
source_revno, source_revision_id = self.last_revision_info()
2268
if revision_id is None:
2269
revno, revision_id = source_revno, source_revision_id
2270
elif source_revision_id == revision_id:
2271
# we know the revno without needing to walk all of history
2272
revno = source_revno
2274
# To figure out the revno for a random revision, we need to build
2275
# the revision history, and count its length.
2276
# We don't care about the order, just how long it is.
2277
# Alternatively, we could start at the current location, and count
2278
# backwards. But there is no guarantee that we will find it since
2279
# it may be a merged revision.
2280
revno = len(list(self.repository.iter_reverse_revision_history(
2282
destination.set_last_revision_info(revno, revision_id)
2284
2259
def _make_tags(self):
2285
2260
return BasicTags(self)