Show More
@@ -2166,21 +2166,33 b' class spanset(object):' | |||||
2166 | """Duck type for baseset class which represents a range of revisions and |
|
2166 | """Duck type for baseset class which represents a range of revisions and | |
2167 | can work lazily and without having all the range in memory |
|
2167 | can work lazily and without having all the range in memory | |
2168 | """ |
|
2168 | """ | |
2169 | def __init__(self, start, end): |
|
2169 | def __init__(self, start, end, hiddenrevs=set()): | |
2170 | self._start = start |
|
2170 | self._start = start | |
2171 | self._end = end |
|
2171 | self._end = end | |
|
2172 | self._hiddenrevs = hiddenrevs | |||
|
2173 | ||||
|
2174 | def _contained(self, rev): | |||
|
2175 | return (rev <= self._start and rev > self._end) or (rev >= self._start | |||
|
2176 | and rev < self._end) | |||
2172 |
|
2177 | |||
2173 | def __iter__(self): |
|
2178 | def __iter__(self): | |
2174 | if self._start <= self._end: |
|
2179 | if self._start <= self._end: | |
2175 |
|
|
2180 | iterrange = xrange(self._start, self._end) | |
2176 | yield r |
|
|||
2177 | else: |
|
2181 | else: | |
2178 |
|
|
2182 | iterrange = xrange(self._start, self._end, -1) | |
|
2183 | ||||
|
2184 | if self._hiddenrevs: | |||
|
2185 | s = self._hiddenrevs | |||
|
2186 | for r in iterrange: | |||
|
2187 | if r not in s: | |||
|
2188 | yield r | |||
|
2189 | else: | |||
|
2190 | for r in iterrange: | |||
2179 | yield r |
|
2191 | yield r | |
2180 |
|
2192 | |||
2181 | def __contains__(self, x): |
|
2193 | def __contains__(self, x): | |
2182 | return (x <= self._start and x > self._end) or (x >= self._start and x< |
|
2194 | return self._contained(x) and not (self._hiddenrevs and rev in | |
2183 |
self._ |
|
2195 | self._hiddenrevs) | |
2184 |
|
2196 | |||
2185 | def __and__(self, x): |
|
2197 | def __and__(self, x): | |
2186 | return lazyset(self, lambda r: r in x) |
|
2198 | return lazyset(self, lambda r: r in x) | |
@@ -2193,7 +2205,14 b' class spanset(object):' | |||||
2193 | return l + baseset(x) |
|
2205 | return l + baseset(x) | |
2194 |
|
2206 | |||
2195 | def __len__(self): |
|
2207 | def __len__(self): | |
2196 | return abs(self._end - self._start) |
|
2208 | if not self._hiddenrevs: | |
|
2209 | return abs(self._end - self._start) | |||
|
2210 | else: | |||
|
2211 | count = 0 | |||
|
2212 | for rev in self._hiddenrevs: | |||
|
2213 | if self._contained(rev): | |||
|
2214 | count += 1 | |||
|
2215 | return abs(self._end - self._start) - count | |||
2197 |
|
2216 | |||
2198 | def __getitem__(self, x): |
|
2217 | def __getitem__(self, x): | |
2199 | # Basic implementation to be changed in future patches. |
|
2218 | # Basic implementation to be changed in future patches. |
General Comments 0
You need to be logged in to leave comments.
Login now