revsfromramge: hard code the single changeset range case
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Wed, 22 Mar 2017 20:34:07 +0100
changeset 2186 57d58f27ffae
parent 2185 6b98ceed0626
child 2187 c583efbaec78
revsfromramge: hard code the single changeset range case That case is trivial and triggering and full stable sort for it seems a bit silly.
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)