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

login
register
mail settings
Submitter Paul Morelle
Date May 22, 2018, 7:34 a.m.
Message ID <787f2b0636c6d6f44235.1526974467@belenos.localdomain>
Download mbox | patch
Permalink /patch/31806/
State Accepted
Headers show

Comments

Paul Morelle - May 22, 2018, 7:34 a.m.
# HG changeset patch
# User Paul Morelle <paul.morelle@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

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.
Yuya Nishihara - May 28, 2018, 1:04 p.m.
On Tue, 22 May 2018 09:34:27 +0200, Paul Morelle wrote:
> # HG changeset patch
> # User Paul Morelle <paul.morelle@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.

Patch

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