merge-slicing: simplify various aspect of the code
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Fri, 24 Mar 2017 05:51:20 +0100
changeset 2215 6d9cadc635d5
parent 2214 14e876c5e1c3
child 2216 de76219b42b8
merge-slicing: simplify various aspect of the code Especially the case were the bottom have single heads is not more efficiently handled.
hgext3rd/evolve/stablerange.py
--- a/hgext3rd/evolve/stablerange.py	Thu Mar 23 14:17:15 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Fri Mar 24 05:51:20 2017 +0100
@@ -418,12 +418,11 @@
         result = []
         allrevs = self.revsfromrange(repo, rangeid)
         bottomrevs = allrevs[:localindex]
-        top = (rangeid[0], globalindex)
-        #
-        rangedepth = self.depthrev(repo, rangeid[0])
-        maxbottomdepth = self.depthrev(repo, bottomrevs[-1])
-        if maxbottomdepth + self.rangelength(repo, top) == rangedepth:
-            bheads = [bottomrevs[-1]]
+
+        if globalindex == self.depthrev(repo, bottomrevs[-1]):
+            # simple case, top revision in the bottom set contains exactly the
+            # revision we needs
+            result.append((bottomrevs[-1], rangeid[1]))
         else:
             bheads = set(bottomrevs)
             parentrevs = cl.parentrevs
@@ -431,23 +430,14 @@
             du = bheads.difference_update
             for r in bottomrevs:
                 du(parents(r, parentrevs))
-            # if len(bheads) == 1:
-            #     assert 1 == len(repo.revs('roots(%ld)', top._revs))
-        if len(bheads) == 1:
-            newhead = bottomrevs[-1]
-            bottomdepth = self.depthrev(repo, newhead)
-            newstart = bottomdepth - len(bottomrevs)
-            bottom = (newhead, newstart)
-            result.append(bottom)
-        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 bottomrevs if r in subset]
                 start = self.depthrev(repo, h) - len(hrevs)
                 entry = (h, start)
                 result.append(entry)
+        # top part is trivial
+        top = (rangeid[0], globalindex)
         result.append(top)
         return result