changeset 2226:83e6933ae00e

subranges: add a utility function to access the cache This is preparing on disk persistence for the value in this cache.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 24 Mar 2017 09:18:50 +0100
parents 81f5ebd9e9d0
children 4b621b56e3a1
files hgext3rd/evolve/stablerange.py
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/stablerange.py	Fri Mar 24 09:15:18 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Fri Mar 24 09:18:50 2017 +0100
@@ -215,9 +215,9 @@
                 seen += 1
                 original.remove(value) # might have been added from other source
             __, rangeid = value
-            if self._subrangescache.get(rangeid) is None:
+            if self._getsub(rangeid) is None:
                 for sub in self.subranges(repo, rangeid):
-                    if self._subrangescache.get(sub) is None:
+                    if self._getsub(sub) is None:
                         heappush(rangeheap, (-sub[0], sub))
         ui.progress(_("filling stablerange cache"), None, total=nbrevs)
 
@@ -260,7 +260,7 @@
         return self.depthrev(repo, headrev) - index
 
     def subranges(self, repo, rangeid):
-        cached = self._subrangescache.get(rangeid)
+        cached = self._getsub(rangeid)
         if cached is not None:
             return cached
         value = self._subranges(repo, rangeid)
@@ -310,6 +310,12 @@
         This mostly exist to help the on disk persistence."""
         self._depthcache[rev] = value
 
+    def _getsub(self, rev):
+        """utility function used to access the subranges cache
+
+        This mostly exist to help the on disk persistence"""
+        return self._subrangescache.get(rev)
+
     def _filestablesortcache(self, sortedrevs, merge):
         if merge not in self._stablesortprepared:
             self._stablesortprepared[merge] = (sortedrevs, len(sortedrevs))
@@ -457,7 +463,7 @@
         reurange = (reusablerev, rangeid[1])
         # if we have an entry for the current range, lets update the cache
         # if we already have subrange for this range, no need to prepare it.
-        if self._subrangescache.get(reurange) is not None:
+        if self._getsub(reurange) is not None:
             return None
 
         # look like we found a relevent parentrange with no cache yet