stablesort: extract a '_revsfrom' method
Walking from the revision is usually simple unless the revision is a merge.
Having this walking logic isolated will help us refine it.
--- a/hgext3rd/evolve/stablesort.py Sun Dec 10 01:48:32 2017 +0100
+++ b/hgext3rd/evolve/stablesort.py Sat Nov 25 18:42:23 2017 -0500
@@ -305,10 +305,17 @@
class stablesortcache(object):
def get(self, repo, rev, limit=None):
- revs = stablesort_mergepoint_head(repo, rev)
- if limit is None:
- return revs
- return revs[-limit:]
+ result = []
+ for r in self._revsfrom(repo, rev):
+ result.append(r)
+ if limit is not None and limit <= len(result):
+ break
+ result.reverse()
+ return result
+
+ def _revsfrom(self, repo, head):
+ for rev in stablesort_mergepoint_head(repo, head)[::-1]:
+ yield rev
_methodmap = {
'branchpoint': stablesort_branchpoint,