comparison mercurial/revset.py @ 22719:21fda9dcd4e8

lazyset: split the iteration logic from the condition filtering logic So that the filter can be reused by `fastasc` or `fastdesc`.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 02 Oct 2014 18:25:37 -0500
parents 7b123e5639f4
children 4388f99c5512
comparison
equal deleted inserted replaced
22718:7b123e5639f4 22719:21fda9dcd4e8
2434 v = c[x] = x in self._subset and self._condition(x) 2434 v = c[x] = x in self._subset and self._condition(x)
2435 return v 2435 return v
2436 return c[x] 2436 return c[x]
2437 2437
2438 def __iter__(self): 2438 def __iter__(self):
2439 return self._iterfilter(self._subset)
2440
2441 def _iterfilter(self, it):
2439 cond = self._condition 2442 cond = self._condition
2440 for x in self._subset: 2443 for x in it:
2441 if cond(x): 2444 if cond(x):
2442 yield x 2445 yield x
2443 2446
2444 def __and__(self, x): 2447 def __and__(self, x):
2445 return lazyset(self, x.__contains__) 2448 return lazyset(self, x.__contains__)