Mercurial > hg
comparison mercurial/revset.py @ 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 |
comparison
equal
deleted
inserted
replaced
20481:a5d7081a4c34 | 20482:a979078bd788 |
---|---|
2127 self._subset.reverse() | 2127 self._subset.reverse() |
2128 | 2128 |
2129 def set(self): | 2129 def set(self): |
2130 return set([r for r in self]) | 2130 return set([r for r in self]) |
2131 | 2131 |
2132 class spanset(object): | |
2133 """Duck type for baseset class which represents a range of revisions and | |
2134 can work lazily and without having all the range in memory | |
2135 """ | |
2136 def __init__(self, start, end): | |
2137 self._start = start | |
2138 self._end = end | |
2139 | |
2140 def __iter__(self): | |
2141 if self._start <= self._end: | |
2142 for r in xrange(self._start, self._end): | |
2143 yield r | |
2144 else: | |
2145 for r in xrange(self._start, self._end, -1): | |
2146 yield r | |
2147 | |
2148 def __contains__(self, x): | |
2149 return (x <= self._start and x > self._end) or (x >= self._start and x< | |
2150 self._end) | |
2151 | |
2132 # tell hggettext to extract docstrings from these functions: | 2152 # tell hggettext to extract docstrings from these functions: |
2133 i18nfunctions = symbols.values() | 2153 i18nfunctions = symbols.values() |