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

Paul Morelle paul.morelle at octobus.net
Mon May 21 17:47:58 EDT 2018


# HG changeset patch
# User Paul Morelle <paul.morelle at octobus.net>
# Date 1524324477 -7200
#      Sat Apr 21 17:27:57 2018 +0200
# Node ID f7f55d6f2966181f243d69b1afa598c12f6c4220
# Parent  fbb85c011ea4c6ba474dbe616f63543cffb5f909
# EXP-Topic semi-snapshots
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r f7f55d6f2966
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.

diff -r fbb85c011ea4 -r f7f55d6f2966 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
@@ -870,10 +870,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


More information about the Mercurial-devel mailing list