hgext3rd/evolve/stablesort.py
changeset 3266 bc173e7f3b6f
parent 3265 70b5bc95efbe
child 3267 f9206b009f48
--- a/hgext3rd/evolve/stablesort.py	Sat Nov 25 18:42:23 2017 -0500
+++ b/hgext3rd/evolve/stablesort.py	Sat Nov 25 18:53:23 2017 -0500
@@ -314,8 +314,23 @@
         return result
 
     def _revsfrom(self, repo, head):
-        for rev in stablesort_mergepoint_head(repo, head)[::-1]:
-            yield rev
+        parentsfunc = repo.changelog.parentrevs
+
+        def parents(rev):
+            return [p for p in parentsfunc(current) if p is not nodemod.nullrev]
+
+        current = head
+        ps = parents(current)
+        while len(ps) == 1:
+            yield current
+            current = ps[0]
+            ps = parents(current)
+
+        if not ps:
+            yield current
+        elif len(ps) == 2:
+            for rev in stablesort_mergepoint_head(repo, current)[::-1]:
+                yield rev
 
 _methodmap = {
     'branchpoint': stablesort_branchpoint,