Mercurial > evolve
changeset 2186:57d58f27ffae
revsfromramge: hard code the single changeset range case
That case is trivial and triggering and full stable sort for it seems a bit
silly.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Wed, 22 Mar 2017 20:34:07 +0100 |
parents | 6b98ceed0626 |
children | c583efbaec78 |
files | hgext3rd/evolve/stablerange.py |
diffstat | 1 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/stablerange.py Wed Mar 22 20:18:01 2017 +0100 +++ b/hgext3rd/evolve/stablerange.py Wed Mar 22 20:34:07 2017 +0100 @@ -230,13 +230,20 @@ def revsfromrange(self, repo, rangeid): revs = self._revsinrangecache.get(rangeid) if revs is None: - # get all revs under heads in stable order - allrevs = self._stablesortcache.get(rangeid[0]) - if allrevs is None: - allrevs = stablesort(repo, [rangeid[0]]) - self._stablesortcache[rangeid[0]] = allrevs - # takes from index - revs = allrevs[rangeid[1]:] + if self.rangelength(repo, rangeid) == 1: + revs = [rangeid[0]] + else: + # get all revs under heads in stable order + # + # note: In the general case we can just walk down and then request + # data about the merge. But I'm not sure this function will be even + # call for the general case. + allrevs = self._stablesortcache.get(rangeid[0]) + if allrevs is None: + allrevs = stablesort(repo, [rangeid[0]]) + self._stablesortcache[rangeid[0]] = allrevs + # takes from index + revs = allrevs[rangeid[1]:] self._revsinrangecache[rangeid] = revs # sanity checks assert len(revs) == self.rangelength(repo, rangeid)