Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revset.py @ 20716:fa1ac5faa7c4
revset: added __nonzero__ method to spanset class
Implemented it in a lazy way, just look for the first non-filtered revision
and return True if there's any revision at all.
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Fri, 14 Mar 2014 09:07:59 -0700 |
parents | 41e1064486f9 |
children | d7b7ec0459c6 |
comparison
equal
deleted
inserted
replaced
20714:41e1064486f9 | 20716:fa1ac5faa7c4 |
---|---|
2488 | 2488 |
2489 def __contains__(self, x): | 2489 def __contains__(self, x): |
2490 return self._contained(x) and not (self._hiddenrevs and rev in | 2490 return self._contained(x) and not (self._hiddenrevs and rev in |
2491 self._hiddenrevs) | 2491 self._hiddenrevs) |
2492 | 2492 |
2493 def __nonzero__(self): | |
2494 for r in self: | |
2495 return True | |
2496 return False | |
2497 | |
2493 def __and__(self, x): | 2498 def __and__(self, x): |
2494 if isinstance(x, baseset): | 2499 if isinstance(x, baseset): |
2495 x = x.set() | 2500 x = x.set() |
2496 if self._start <= self._end: | 2501 if self._start <= self._end: |
2497 return orderedlazyset(self, lambda r: r in x) | 2502 return orderedlazyset(self, lambda r: r in x) |