generatorset: get list-based fast iterations after the generator is consumed
When all revisions are known, we shortcut most of the class logic to use list
iteration instead. The cost of the sort is expected to be non-significant. The
list creation and sorting could be done lazily in the future. We have to copy
the list to not break existing iterator created before we finished consuming the
generator.
--- a/mercurial/revset.py Fri Oct 03 20:48:28 2014 -0700
+++ b/mercurial/revset.py Fri Oct 03 21:01:30 2014 -0700
@@ -2621,6 +2621,7 @@
gen: a generator producing the values for the generatorset.
"""
self._gen = gen
+ self._asclist = None
self._cache = {}
self._genlist = []
self._finished = False
@@ -2712,7 +2713,13 @@
cache[item] = True
genlist(item)
yield item
- self._finished = True
+ if not self._finished:
+ self._finished = True
+ asc = self._genlist[:]
+ asc.sort()
+ self._asclist = asc
+ self.fastasc = asc.__iter__
+ self.fastdesc = asc.__reversed__
def set(self):
return self