# HG changeset patch # User Pierre-Yves David # Date 1511654003 18000 # Node ID bc173e7f3b6f23ed43fdcad9d158d08e159ed953 # Parent 70b5bc95efbe4de763634401b3a2a552ae415812 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. diff -r 70b5bc95efbe -r bc173e7f3b6f hgext3rd/evolve/stablesort.py --- 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,