[PATCH 2 of 2 V2] revlog: make chainbase cache its result for the correct revision

Yuya Nishihara yuya at tcha.org
Mon May 28 09:04:43 EDT 2018


On Tue, 22 May 2018 09:34:27 +0200, Paul Morelle wrote:
> # HG changeset patch
> # User Paul Morelle <paul.morelle at octobus.net>
> # Date 1524324477 -7200
> #      Sat Apr 21 17:27:57 2018 +0200
> # Node ID 787f2b0636c6d6f44235dcd8436f6d8fc5f1a6cb
> # Parent  c0ac96176ebefaf19cd2d368281c180c575c31f2
> # EXP-Topic semi-snapshots
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 787f2b0636c6
> revlog: make chainbase cache its result for the correct revision

Queued, thanks.

> Previously, as 'rev' was our iterator, we were always caching the chain base
> for the second revision of the chain, or for the base itself.
> 
> diff -r c0ac96176ebe -r 787f2b0636c6 mercurial/revlog.py
> --- a/mercurial/revlog.py	Wed Mar 07 11:10:22 2018 +0100
> +++ b/mercurial/revlog.py	Sat Apr 21 17:27:57 2018 +0200
> @@ -877,10 +877,11 @@
>              return base
>  
>          index = self.index
> -        base = index[rev][3]
> -        while base != rev:
> -            rev = base
> -            base = index[rev][3]
> +        iterrev = rev
> +        base = index[iterrev][3]
> +        while base != iterrev:
> +            iterrev = base
> +            base = index[iterrev][3]
>  
>          self._chainbasecache[rev] = base
>          return base

+CC Greg since I'm not 100% sure if there were no intent to prefer caching
the bottom revision.


More information about the Mercurial-devel mailing list