revsfromrange: remove reference to '_revs' in merge slicing
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Wed, 22 Mar 2017 20:44:29 +0100
changeset 2190 f4cc3cf27a3a
parent 2189 40b0e1dbed90
child 2191 dd5b948a98b4
revsfromrange: remove reference to '_revs' in merge slicing Given '_revs' is a property from the cache, we use the official method of the object we are on instead. That method should be using the same cache than the property if available.
hgext3rd/evolve/stablerange.py
--- a/hgext3rd/evolve/stablerange.py	Wed Mar 22 20:37:27 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Wed Mar 22 20:44:29 2017 +0100
@@ -349,34 +349,36 @@
         cl = repo.changelog
 
         result = []
-        bottom = rangeid._revs[:localindex]
-        top = stablerange(repo, rangeid[0], globalindex, rangeid._revs[localindex:])
+        allrevs = self.revsfromrange(repo, rangeid)
+        toprevs = allrevs[localindex:]
+        bottomrevs = allrevs[:localindex]
+        top = stablerange(repo, rangeid[0], globalindex, toprevs)
         #
         rangedepth = repo.stablerange.depthrev(repo, rangeid[0])
-        toprootdepth = repo.stablerange.depthrev(repo, top._revs[0])
+        toprootdepth = repo.stablerange.depthrev(repo, toprevs[0])
         if toprootdepth + self.rangelength(repo, top) == rangedepth + 1:
-            bheads = [bottom[-1]]
+            bheads = [bottomrevs[-1]]
         else:
-            bheads = set(bottom)
+            bheads = set(bottomrevs)
             parentrevs = cl.parentrevs
             du = bheads.difference_update
-            for r in bottom:
+            for r in bottomrevs:
                 du(parentrevs(r))
             # if len(bheads) == 1:
             #     assert 1 == len(repo.revs('roots(%ld)', top._revs))
         if len(bheads) == 1:
-            newhead = bottom[-1]
+            newhead = bottomrevs[-1]
             bottomdepth = repo.stablerange.depthrev(repo, newhead)
-            newstart = bottomdepth - len(bottom)
-            result.append(stablerange(repo, newhead, newstart, bottom))
+            newstart = bottomdepth - len(bottomrevs)
+            result.append(stablerange(repo, newhead, newstart, bottomrevs))
         else:
             # assert 1 < len(bheads), (toprootdepth, len(top), len(rangeid))
             cl = repo.changelog
             for h in bheads:
                 subset = cl.ancestors([h], inclusive=True)
-                hrevs = [r for r in bottom if r in subset]
+                hrevs = [r for r in bottomrevs if r in subset]
                 start = repo.stablerange.depthrev(repo, h) - len(hrevs)
-                entry = stablerange(repo, h, start, [r for r in bottom if r in subset])
+                entry = stablerange(repo, h, start, [r for r in bottomrevs if r in subset])
                 result.append(entry)
         result.append(top)
         return result