# HG changeset patch # User Pierre-Yves David # Date 1490211247 -3600 # Node ID 57d58f27ffaeb291d6f52e84cf8b121104ea3b1b # Parent 6b98ceed06261ad8b2618f0d0820fe647d5e318a revsfromramge: hard code the single changeset range case That case is trivial and triggering and full stable sort for it seems a bit silly. diff -r 6b98ceed0626 -r 57d58f27ffae hgext3rd/evolve/stablerange.py --- 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)