Mercurial > evolve
changeset 3265:70b5bc95efbe
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.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 25 Nov 2017 18:42:23 -0500 |
parents | 383ec26247b3 |
children | bc173e7f3b6f |
files | hgext3rd/evolve/stablesort.py |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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,