# HG changeset patch # User Anton Shestakov # Date 1615901111 -28800 # Node ID 13b108c3782e17c91f83a2a07deb59e6443cacad # Parent f4b762cf41c0fffcd03ead6c8d6a3b53aa60fcdf 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+. diff -r f4b762cf41c0 -r 13b108c3782e hgext3rd/evolve/genericcaches.py --- 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 diff -r f4b762cf41c0 -r 13b108c3782e hgext3rd/evolve/obscache.py --- 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 diff -r f4b762cf41c0 -r 13b108c3782e hgext3rd/evolve/stablerange.py --- 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