Mercurial > hg
changeset 20610:34bb07e70c68
revset: added filter method to revset classes
This method will replace the creation of lazysets inside the revset methods.
Instead, the classes that handle lazy structures will create them based on
their current order.
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Thu, 06 Feb 2014 17:18:11 -0800 |
parents | 56ecc82fcd67 |
children | 6490f8385391 |
files | mercurial/revset.py |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Wed Feb 05 15:24:08 2014 -0800 +++ b/mercurial/revset.py Thu Feb 06 17:18:11 2014 -0800 @@ -2146,6 +2146,9 @@ l = [r for r in x if r not in s] return baseset(list(self) + l) + def filter(self, l): + return lazyset(self, l) + class lazyset(object): """Duck type for baseset class which iterates lazily over the revisions in the subset and contains a function which tests for membership in the @@ -2210,6 +2213,9 @@ def set(self): return set([r for r in self]) + def filter(self, l): + return lazyset(self, l) + class orderedlazyset(lazyset): """Subclass of lazyset which subset can be ordered either ascending or descendingly @@ -2218,6 +2224,9 @@ super(orderedlazyset, self).__init__(subset, condition) self._ascending = ascending + def filter(self, l): + return orderedlazyset(self, l, ascending=self._ascending) + class generatorset(object): """Wrapper structure for generators that provides lazy membership and can be iterated more than once. @@ -2357,5 +2366,11 @@ def set(self): return self + def filter(self, l): + if self._start <= self._end: + return orderedlazyset(self, l) + else: + return orderedlazyset(self, l, ascending=False) + # tell hggettext to extract docstrings from these functions: i18nfunctions = symbols.values()