Mercurial > hg
comparison mercurial/revset.py @ 20428:2e33cda452f6
revset: added basic operations to lazyset
Added methods __add__, __sub__ and __and__ to duck type more methods in
baseset
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Thu, 06 Feb 2014 14:25:37 -0800 |
parents | 4a9191ca848e |
children | f5b560c60bcd |
comparison
equal
deleted
inserted
replaced
20427:4a9191ca848e | 20428:2e33cda452f6 |
---|---|
2088 cond = self._condition | 2088 cond = self._condition |
2089 for x in self._subset: | 2089 for x in self._subset: |
2090 if cond(x): | 2090 if cond(x): |
2091 yield x | 2091 yield x |
2092 | 2092 |
2093 def __and__(self, x): | |
2094 return lazyset(self, lambda r: r in x) | |
2095 | |
2096 def __sub__(self, x): | |
2097 return lazyset(self, lambda r: r not in x) | |
2098 | |
2099 def __add__(self, x): | |
2100 l = baseset([r for r in self]) | |
2101 return l + baseset(x) | |
2102 | |
2093 # tell hggettext to extract docstrings from these functions: | 2103 # tell hggettext to extract docstrings from these functions: |
2094 i18nfunctions = symbols.values() | 2104 i18nfunctions = symbols.values() |