changeset 5853:13b108c3782e stable

evolve: use cl.tiprev() instead of len(cl) - 1 We have this nice method of revlogs that will make code slightly easier to read, why not use it. Revlogs also have a .tip() method to return tip as node hash, but only in 5.3+.
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 16 Mar 2021 21:25:11 +0800
parents f4b762cf41c0
children b0f35c0a762f
files hgext3rd/evolve/genericcaches.py hgext3rd/evolve/obscache.py hgext3rd/evolve/stablerange.py
diffstat 3 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/genericcaches.py	Mon Mar 15 19:21:23 2021 +0800
+++ b/hgext3rd/evolve/genericcaches.py	Tue Mar 16 21:25:11 2021 +0800
@@ -153,10 +153,9 @@
         """use a cachekey to fetch incremental data
 
         Exists as its own method to help subclass to reuse it."""
-        tiprev = len(cl) - 1
+        tiprev = cl.tiprev()
         tipnode = cl.node(tiprev)
         newkey = (tiprev, tipnode)
-        tiprev = len(cl) - 1
         if newkey == cachekey:
             return False, [], newkey
         keyrev, keynode = cachekey
--- a/hgext3rd/evolve/obscache.py	Mon Mar 15 19:21:23 2021 +0800
+++ b/hgext3rd/evolve/obscache.py	Tue Mar 16 21:25:11 2021 +0800
@@ -195,7 +195,7 @@
         # update the key from the new data
         key = list(self._cachekey)
         if revs:
-            key[0] = len(cl) - 1
+            key[0] = cl.tiprev()
             key[1] = cl.node(key[0])
         if obsmarkers:
             key[2] += len(obsmarkers)
@@ -213,7 +213,7 @@
         ### Is the cache valid ?
         keytiprev, keytipnode, keyobslength, keyobssize, keyobskey = key
         # check for changelog strip
-        tiprev = len(changelog) - 1
+        tiprev = changelog.tiprev()
         if (tiprev < keytiprev
                 or changelog.node(keytiprev) != keytipnode):
             return None
@@ -251,7 +251,7 @@
             reset = True
             key = self.emptykey
             obssize, obskey = obsstore.cachekey()
-            tiprev = len(cl) - 1
+            tiprev = cl.tiprev()
         else:
             tiprev, obssize, obskey = status
 
--- a/hgext3rd/evolve/stablerange.py	Mon Mar 15 19:21:23 2021 +0800
+++ b/hgext3rd/evolve/stablerange.py	Tue Mar 16 21:25:11 2021 +0800
@@ -953,7 +953,7 @@
         starttime = util.timer()
 
         if upto is None:
-            upto = len(cl) - 1
+            upto = cl.tiprev()
         if self._tiprev is None:
             revs = cl.revs(stop=upto)
             nbrevs = upto + 1