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

login
register
mail settings
Submitter Paul Morelle
Date May 21, 2018, 9:47 p.m.
Message ID <f7f55d6f2966181f243d.1526939278@belenos.localdomain>
Download mbox | patch
Permalink /patch/31797/
State Accepted
Headers show

Comments

Paul Morelle - May 21, 2018, 9:47 p.m.
# HG changeset patch
# User Paul Morelle <paul.morelle@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.

Patch

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