##// END OF EJS Templates
revset: add documentation and comment for _generatorset...
Pierre-Yves David -
r20739:1b4f2399 default
parent child Browse files
Show More
@@ -2554,6 +2554,9 b' class _generatorset(object):'
2554 internally
2554 internally
2555 """
2555 """
2556 def __init__(self, gen):
2556 def __init__(self, gen):
2557 """
2558 gen: a generator producing the values for the generatorset.
2559 """
2557 self._gen = gen
2560 self._gen = gen
2558 self._iter = iter(gen)
2561 self._iter = iter(gen)
2559 self._cache = {}
2562 self._cache = {}
@@ -2565,6 +2568,7 b' class _generatorset(object):'
2565 if x in self._cache:
2568 if x in self._cache:
2566 return self._cache[x]
2569 return self._cache[x]
2567
2570
2571 # Use __iter__ which caches values and stores them into self._genlist
2568 for l in self:
2572 for l in self:
2569 if l == x:
2573 if l == x:
2570 return True
2574 return True
@@ -2575,9 +2579,12 b' class _generatorset(object):'
2575
2579
2576 def __iter__(self):
2580 def __iter__(self):
2577 if self._iterated:
2581 if self._iterated:
2582 # At least a part of the list should be cached if iteration has
2583 # started over the generatorset.
2578 for l in self._genlist:
2584 for l in self._genlist:
2579 yield l
2585 yield l
2580 else:
2586 else:
2587 # Starting iteration over the generatorset.
2581 self._iterated = True
2588 self._iterated = True
2582
2589
2583 for item in self._gen:
2590 for item in self._gen:
@@ -2585,13 +2592,14 b' class _generatorset(object):'
2585 self._genlist.append(item)
2592 self._genlist.append(item)
2586 yield item
2593 yield item
2587
2594
2595 # Iteration over the generator has finished. Whole value list should be
2596 # cached in self._genlist
2588 self._finished = True
2597 self._finished = True
2589
2598
2590 def set(self):
2599 def set(self):
2591 return self
2600 return self
2592
2601
2593 def sort(self, reverse=False):
2602 def sort(self, reverse=False):
2594 # Basic implementation to be changed in future patches
2595 if not self._finished:
2603 if not self._finished:
2596 for i in self:
2604 for i in self:
2597 continue
2605 continue
General Comments 0
You need to be logged in to leave comments. Login now