Mercurial > hg
changeset 20482:a979078bd788
revset: added spanset class to represent revision ranges
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Wed, 12 Feb 2014 10:16:21 -0800 |
parents | a5d7081a4c34 |
children | ed57358398af |
files | mercurial/revset.py |
diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Thu Feb 06 08:36:11 2014 -0800 +++ b/mercurial/revset.py Wed Feb 12 10:16:21 2014 -0800 @@ -2129,5 +2129,25 @@ def set(self): return set([r for r in 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 + """ + def __init__(self, start, end): + self._start = start + self._end = end + + def __iter__(self): + if self._start <= self._end: + for r in xrange(self._start, self._end): + yield r + else: + for r in xrange(self._start, self._end, -1): + yield r + + def __contains__(self, x): + return (x <= self._start and x > self._end) or (x >= self._start and x< + self._end) + # tell hggettext to extract docstrings from these functions: i18nfunctions = symbols.values()