Comments
Patch
@@ -2147,6 +2147,39 @@
def set(self):
return set([r for r in self])
+class generatorset(object):
+ def __init__(self, gen):
+ self._gen = gen
+ self._iter = iter(gen)
+ self._pcache = set()
+ self._ncache = set()
+
+ def __contains__(self, x):
+ if x in self._pcache:
+ return True
+ if x in self._ncache:
+ return False
+
+ while True:
+ try:
+ l = self._iter.next()
+ self._pcache.add(l)
+ if l == x:
+ return True
+ except (StopIteration):
+ break
+
+ self._ncache.add(x)
+ return False
+
+ def __iter__(self):
+ for item in self._gen:
+ self._pcache.add(item)
+ yield item
+
+ def set(self):
+ return self
+
class spanset(object):
"""Duck type for baseset class which represents a range of revisions and
can work lazily and without having all the range in memory