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.
--- 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,