stablerange: move revs computation within the main class
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Wed, 22 Mar 2017 20:05:21 +0100
changeset 2183 3c2992afee71
parent 2182 884f6309eae7
child 2184 3ec0be20e365
stablerange: move revs computation within the main class We still need to compute the revision withing a range when we slice a merge. This is the last large logic that remains in the individual class and we migrate is on the main class.
hgext3rd/evolve/stablerange.py
--- a/hgext3rd/evolve/stablerange.py	Wed Mar 22 19:42:37 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Wed Mar 22 20:05:21 2017 +0100
@@ -211,6 +211,15 @@
         self._subrangescache[rangeid] = value
         return value
 
+    def revsfromrange(self, repo, rangeid):
+        # get all revs under heads in stable order
+        allrevs = stablesort(repo, [rangeid[0]])
+        # takes from index
+        revs = allrevs[rangeid[1]:]
+        # sanity checks
+        assert len(revs) == self.rangelength(repo, rangeid)
+        return revs
+
     @staticmethod
     def _depthmerge(cl, rev, p1, p2, stack, cache):
         # sub method to simplify the main 'depthrev' one
@@ -370,10 +379,7 @@
 
     @util.propertycache
     def _revs(self):
-        length = self._repo.stablerange.rangelength(self._repo, self)
-        r = stablesort(self._repo, [self[0]])[self[1]:]
-        assert len(r) == length, (self[0], self[1], len(r), length)
-        return r
+        return self._repo.stablerange.revsfromrange(self._repo, self)
 
 @eh.reposetup
 def setupcache(ui, repo):