changeset 3266:bc173e7f3b6f

stablesort: simplify processing of non-merge changesets As long as a changeset as only one parent, the next element in the sort (starting from the head) has to be that parent. We detect and take advantage of that shortcut in the non-merge case.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 25 Nov 2017 18:53:23 -0500
parents 70b5bc95efbe
children f9206b009f48
files hgext3rd/evolve/stablesort.py
diffstat 1 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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,