Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 20707:1d5d6f622b94
revset: made descgeneratorset a private class
This class is not supposed to be used outside revset.py since it only
wraps content that is used by baseset typed classes.
It only gets created by revset operations or private methods.
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Wed, 12 Mar 2014 17:19:46 -0700 |
parents | efb34b066e7a |
children | 17c89e5a5627 |
comparison
equal
deleted
inserted
replaced
20706:efb34b066e7a | 20707:1d5d6f622b94 |
---|---|
44 yield current | 44 yield current |
45 for parent in cl.parentrevs(current)[:cut]: | 45 for parent in cl.parentrevs(current)[:cut]: |
46 if parent != node.nullrev: | 46 if parent != node.nullrev: |
47 heapq.heappush(h, -parent) | 47 heapq.heappush(h, -parent) |
48 | 48 |
49 return descgeneratorset(iterate()) | 49 return _descgeneratorset(iterate()) |
50 | 50 |
51 def _revdescendants(repo, revs, followfirst): | 51 def _revdescendants(repo, revs, followfirst): |
52 """Like revlog.descendants() but supports followfirst.""" | 52 """Like revlog.descendants() but supports followfirst.""" |
53 cut = followfirst and 1 or None | 53 cut = followfirst and 1 or None |
54 | 54 |
2411 break | 2411 break |
2412 | 2412 |
2413 self._cache[x] = False | 2413 self._cache[x] = False |
2414 return False | 2414 return False |
2415 | 2415 |
2416 class descgeneratorset(_generatorset): | 2416 class _descgeneratorset(_generatorset): |
2417 """ Same structure as _generatorset but stops iterating after it goes past | 2417 """Wrap a generator of descending elements for lazy iteration |
2418 | |
2419 Same structure as _generatorset but stops iterating after it goes past | |
2418 the value when asked for membership and the element is not contained | 2420 the value when asked for membership and the element is not contained |
2421 | |
2422 This class does not duck-type baseset and it's only supposed to be used | |
2423 internally | |
2419 """ | 2424 """ |
2420 def __contains__(self, x): | 2425 def __contains__(self, x): |
2421 if x in self._cache: | 2426 if x in self._cache: |
2422 return self._cache[x] | 2427 return self._cache[x] |
2423 | 2428 |