changeset 2219:d83bf4773433

stablerange: rearrange the code picking subrange to warm Same logic, as the previous changesets, we prepare the code before adding merge support.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 24 Mar 2017 08:31:10 +0100
parents 9e30934d4487
children 0b6745b91d6d
files hgext3rd/evolve/stablerange.py
diffstat 1 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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])