stablesort: abstract all cache access
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 20 Dec 2017 23:08:31 +0100
changeset 3334 db8feb404792
parent 3333 96d1cf475c19
child 3335 0d83fb5c5015
stablesort: abstract all cache access This prepare an on disk version of the cache
hgext3rd/evolve/stablesort.py
--- a/hgext3rd/evolve/stablesort.py	Mon Dec 18 20:04:50 2017 +0100
+++ b/hgext3rd/evolve/stablesort.py	Wed Dec 20 23:08:31 2017 +0100
@@ -330,10 +330,10 @@
         return result
 
     def getjumps(self, repo, rev):
-        if rev not in self._jumps:
+        if not self._hasjumpsdata(rev):
             parents = repo.changelog.parentrevs(rev)
             if parents[1] == nodemod.nullrev:
-                self._jumps[rev] = None
+                self._setjumps(rev, None)
             else:
                 # merge ! warn the cache
                 tiebreaker = _mergepoint_tie_breaker(repo)
@@ -341,7 +341,16 @@
                 for r in self.walkfrom(repo, rev):
                     if r == minparent:
                         break
-        return self._jumps[rev]
+        return self._getjumps(rev)
+
+    def _hasjumpsdata(self, rev):
+        return rev in self._jumps
+
+    def _getjumps(self, rev):
+        return self._jumps.get(rev)
+
+    def _setjumps(self, rev, jumps):
+        self._jumps[rev] = jumps
 
     def walkfrom(self, repo, head):
         tiebreaker = _mergepoint_tie_breaker(repo)
@@ -374,7 +383,7 @@
             previous_current_1 = current
             assert previous_current_1 is not previous_current_2
 
-            jumps = self._jumps.get(current)
+            jumps = self._getjumps(current)
             if jumps is not None:
                 # we have enough cached information to directly iterate over
                 # the exclusive size.
@@ -416,7 +425,7 @@
                 if rev == current:
                     recordjump(rev, lower_parent, 1)
 
-                self._jumps[current] = jumps
+                self._setjumps(current, jumps)
 
                 current = lower_parent