[MERGE] fast-path the common case of _synchronise_history

Aaron Bentley aaron.bentley at utoronto.ca
Wed Aug 22 12:43:17 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robert Collins wrote:
> _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)))


^^^ This looks redundant with earlier 2041-2046:

        source_revno, source_revision_id = self.last_revision_info()
        if revision_id is None:
            revno, revision_id = source_revno, source_revision_id
        elif source_revision_id == revision_id:
            # we know the revno without needing to walk all of history
            revno = source_revno

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGzCFV0F+nu1YWqI0RAmE2AJ0ZdheOt807wWCuVRKaT0zBUP040QCfWrpj
UqPuOOFW0ZKevCidV6GzqcA=
=/Uy3
-----END PGP SIGNATURE-----



More information about the bazaar mailing list