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