2144 def __add__(self, x): |
2144 def __add__(self, x): |
2145 s = self.set() |
2145 s = self.set() |
2146 l = [r for r in x if r not in s] |
2146 l = [r for r in x if r not in s] |
2147 return baseset(list(self) + l) |
2147 return baseset(list(self) + l) |
2148 |
2148 |
|
2149 def filter(self, l): |
|
2150 return lazyset(self, l) |
|
2151 |
2149 class lazyset(object): |
2152 class lazyset(object): |
2150 """Duck type for baseset class which iterates lazily over the revisions in |
2153 """Duck type for baseset class which iterates lazily over the revisions in |
2151 the subset and contains a function which tests for membership in the |
2154 the subset and contains a function which tests for membership in the |
2152 revset |
2155 revset |
2153 """ |
2156 """ |
2208 self._subset.reverse() |
2211 self._subset.reverse() |
2209 |
2212 |
2210 def set(self): |
2213 def set(self): |
2211 return set([r for r in self]) |
2214 return set([r for r in self]) |
2212 |
2215 |
|
2216 def filter(self, l): |
|
2217 return lazyset(self, l) |
|
2218 |
2213 class orderedlazyset(lazyset): |
2219 class orderedlazyset(lazyset): |
2214 """Subclass of lazyset which subset can be ordered either ascending or |
2220 """Subclass of lazyset which subset can be ordered either ascending or |
2215 descendingly |
2221 descendingly |
2216 """ |
2222 """ |
2217 def __init__(self, subset, condition, ascending=True): |
2223 def __init__(self, subset, condition, ascending=True): |
2218 super(orderedlazyset, self).__init__(subset, condition) |
2224 super(orderedlazyset, self).__init__(subset, condition) |
2219 self._ascending = ascending |
2225 self._ascending = ascending |
|
2226 |
|
2227 def filter(self, l): |
|
2228 return orderedlazyset(self, l, ascending=self._ascending) |
2220 |
2229 |
2221 class generatorset(object): |
2230 class generatorset(object): |
2222 """Wrapper structure for generators that provides lazy membership and can |
2231 """Wrapper structure for generators that provides lazy membership and can |
2223 be iterated more than once. |
2232 be iterated more than once. |
2224 When asked for membership it generates values until either it finds the |
2233 When asked for membership it generates values until either it finds the |
2355 self._start, self._end = self._end + 1, self._start + 1 |
2364 self._start, self._end = self._end + 1, self._start + 1 |
2356 |
2365 |
2357 def set(self): |
2366 def set(self): |
2358 return self |
2367 return self |
2359 |
2368 |
|
2369 def filter(self, l): |
|
2370 if self._start <= self._end: |
|
2371 return orderedlazyset(self, l) |
|
2372 else: |
|
2373 return orderedlazyset(self, l, ascending=False) |
|
2374 |
2360 # tell hggettext to extract docstrings from these functions: |
2375 # tell hggettext to extract docstrings from these functions: |
2361 i18nfunctions = symbols.values() |
2376 i18nfunctions = symbols.values() |