[MERGE] fast-path the common case of _synchronise_history
Robert Collins
robertc at robertcollins.net
Wed Aug 22 08:58:15 BST 2007
_synchronize_history is called with a revision_id that is not-None in
all cases I could find; this means that the fast path of using
last_revision_info is never triggered; this patch enables a check of
last_revision_info as a cheap way to map the common case.
-Rob
=== modified file 'bzrlib/branch.py'
--- bzrlib/branch.py 2007-08-20 13:07:12 +0000
+++ bzrlib/branch.py 2007-08-22 07:50:19 +0000
@@ -2034,14 +2034,18 @@
# we know the revno without needing to walk all of history
revno = source_revno
else:
- # To figure out the revno for a random revision, we need to build
- # the revision history, and count its length.
- # We don't care about the order, just how long it is.
- # Alternatively, we could start at the current location, and count
- # backwards. But there is no guarantee that we will find it since
- # it may be a merged revision.
- revno = len(list(self.repository.iter_reverse_revision_history(
- revision_id)))
+ # usually when revision_id is supplied it is the tip - try
+ # for the fast_path
+ revno, tip_revision_id = self.last_revision_info()
+ if tip_revision_id != revision_id:
+ # To figure out the revno for a random revision, we need to
+ # build the revision history, and count its length. We don't
+ # care about the order, just how long it is. Alternatively, we
+ # could start at the current location, and count backwards. But
+ # there is no guarantee that we will find it since it may be a
+ # merged revision.
+ revno = len(list(self.repository.iter_reverse_revision_history(
+ revision_id)))
destination.set_last_revision_info(revno, revision_id)
def _make_tags(self):
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070822/32f9d12b/attachment.pgp
More information about the bazaar
mailing list