changeset 22755:f9a825b593be

generatorset: make it possible to use gen as fastasc or fastdesc We gain a parameter to inform that the generator is ascending or descending. If the generator is ordered, it is also used for the `fastasc` or `fastdesc` version. The _ascgeneratorset and _descgeneratorset class will be removed soon.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 03 Oct 2014 12:36:08 -0500
parents 1119e544cd2d
children 5308f21c049e
files mercurial/revset.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Fri Oct 03 03:19:00 2014 -0500
+++ b/mercurial/revset.py	Fri Oct 03 12:36:08 2014 -0500
@@ -2622,7 +2622,7 @@
     This class does not duck-type baseset and it's only supposed to be used
     internally
     """
-    def __init__(self, gen):
+    def __init__(self, gen, iterasc=None):
         """
         gen: a generator producing the values for the generatorset.
         """
@@ -2630,6 +2630,11 @@
         self._cache = {}
         self._genlist = baseset([])
         self._finished = False
+        if iterasc is not None:
+            if iterasc:
+                self.fastasc = self.__iter__
+            else:
+                self.fastdesc = self.__iter__
 
     def __nonzero__(self):
         for r in self: