changeset 2204:61a8b51348a1

subranges: detach cache logic from computation logic Having both the logic around cache checking and setting makes is a bit harder to follow. In addition, this allow to gather the computation logic next to the other related function.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Thu, 23 Mar 2017 10:19:59 +0100
parents 8a2e1f6e5443
children bd5e2496e5cd
files hgext3rd/evolve/stablerange.py
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/stablerange.py	Thu Mar 23 10:07:21 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Thu Mar 23 10:19:59 2017 +0100
@@ -223,11 +223,7 @@
         cached = self._subrangescache.get(rangeid)
         if cached is not None:
             return cached
-        if self.rangelength(repo, rangeid) == 1:
-            value = []
-        else:
-            slicepoint = self._slicepoint(repo, rangeid)
-            value = self._slicesrangeat(repo, rangeid, slicepoint)
+        value = self._subranges(repo, rangeid)
         self._subrangescache[rangeid] = value
         return value
 
@@ -298,6 +294,12 @@
             revdepth += len(cl.findmissingrevs(common=[anc], heads=[rev]))
         return revdepth
 
+    def _subranges(self, repo, rangeid):
+        if self.rangelength(repo, rangeid) == 1:
+            return []
+        slicepoint = self._slicepoint(repo, rangeid)
+        return self._slicesrangeat(repo, rangeid, slicepoint)
+
     def _slicepoint(self, repo, rangeid):
         rangedepth = self.depthrev(repo, rangeid[0])
         step = _hlp2(rangedepth)