depth: add a utility function to set the cache
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Fri, 24 Mar 2017 09:15:18 +0100
changeset 2225 81f5ebd9e9d0
parent 2224 49776d324d1a
child 2226 83e6933ae00e
depth: add a utility function to set the cache This is preparing on disk persistence for the value in this cache.
hgext3rd/evolve/stablerange.py
--- a/hgext3rd/evolve/stablerange.py	Fri Mar 24 09:01:25 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Fri Mar 24 09:15:18 2017 +0100
@@ -249,7 +249,7 @@
                 # merge case
                 revdepth = self._depthmerge(cl, current, p1, p2, stack)
             if revdepth is not None:
-                self._depthcache[current] = revdepth
+                self._setdepth(current, revdepth)
                 stack.pop()
         # actual_depth = len(list(cl.ancestors([rev], inclusive=True)))
         # assert revdepth == actual_depth, (rev, revdepth, actual_depth)
@@ -304,6 +304,12 @@
         This mostly exist to help the on disk persistence."""
         return self._depthcache.get(rev)
 
+    def _setdepth(self, rev, value):
+        """utility function used to set the depth cache
+
+        This mostly exist to help the on disk persistence."""
+        self._depthcache[rev] = value
+
     def _filestablesortcache(self, sortedrevs, merge):
         if merge not in self._stablesortprepared:
             self._stablesortprepared[merge] = (sortedrevs, len(sortedrevs))