Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 20612:60c308b932eb
revset: added basic operators to orderedlazyset
Now __and__ and __sub__ return orderedlazyset.
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Thu, 06 Feb 2014 17:42:08 -0800 |
parents | 6490f8385391 |
children | 10433163bf57 |
comparison
equal
deleted
inserted
replaced
20611:6490f8385391 | 20612:60c308b932eb |
---|---|
2225 self._ascending = ascending | 2225 self._ascending = ascending |
2226 | 2226 |
2227 def filter(self, l): | 2227 def filter(self, l): |
2228 return orderedlazyset(self, l, ascending=self._ascending) | 2228 return orderedlazyset(self, l, ascending=self._ascending) |
2229 | 2229 |
2230 def __and__(self, x): | |
2231 return orderedlazyset(self, lambda r: r in x, | |
2232 ascending=self._ascending) | |
2233 | |
2234 def __sub__(self, x): | |
2235 return orderedlazyset(self, lambda r: r not in x, | |
2236 ascending=self._ascending) | |
2237 | |
2230 class generatorset(object): | 2238 class generatorset(object): |
2231 """Wrapper structure for generators that provides lazy membership and can | 2239 """Wrapper structure for generators that provides lazy membership and can |
2232 be iterated more than once. | 2240 be iterated more than once. |
2233 When asked for membership it generates values until either it finds the | 2241 When asked for membership it generates values until either it finds the |
2234 requested one or has gone through all the elements in the generator | 2242 requested one or has gone through all the elements in the generator |