stablerange: rearrange the code picking subrange to warm
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Fri, 24 Mar 2017 08:31:10 +0100
changeset 2219 d83bf4773433
parent 2218 9e30934d4487
child 2220 0b6745b91d6d
stablerange: rearrange the code picking subrange to warm Same logic, as the previous changesets, we prepare the code before adding merge support.
hgext3rd/evolve/stablerange.py
--- a/hgext3rd/evolve/stablerange.py	Fri Mar 24 08:20:36 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Fri Mar 24 08:31:10 2017 +0100
@@ -342,7 +342,7 @@
         stack = []
         current = rangeid
         while current is not None:
-            current = self._unpreparedparentrange(repo, current, slicepoint)
+            current = self._cold_reusable(repo, current, slicepoint)
             if current is not None:
                 stack.append(current)
         while stack:
@@ -350,7 +350,7 @@
             self.subranges(repo, stack.pop())
         return self._slicesrangeat(repo, rangeid, slicepoint)
 
-    def _unpreparedparentrange(self, repo, rangeid, slicepoint):
+    def _cold_reusable(self, repo, rangeid, slicepoint):
         """return parent range that it would be useful to prepare to slice
         rangeid at slicepoint
 
@@ -360,16 +360,19 @@
         p1, p2 = self._parents(rangeid[0], repo.changelog.parentrevs)
         if p2 != nodemod.nullrev:
             return None
-        parentrange = (p1, rangeid[1])
+        reusablerev = p1
+        # if we reached the slicepoint, no need to go further
+        if self.depthrev(repo, reusablerev) <= slicepoint:
+            return None
+
+        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(parentrange) is not None:
+        if self._subrangescache.get(reurange) is not None:
             return None
-        # if we reached the slicepoint, no need to go further
-        if self.depthrev(repo, parentrange[0]) == slicepoint:
-            return None
+
         # look like we found a relevent parentrange with no cache yet
-        return parentrange
+        return reurange
 
     def _slicepoint(self, repo, rangeid):
         rangedepth = self.depthrev(repo, rangeid[0])