Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 20712:c152e538b85b
revset: added ascending attribute to addset class
In case both collections are in an ascending/descending order then we will be
able to iterate them lazily while keeping the order.
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Tue, 11 Mar 2014 16:52:15 -0700 |
parents | b95490cf8abd |
children | 6a1a4c212d50 |
comparison
equal
deleted
inserted
replaced
20711:b95490cf8abd | 20712:c152e538b85b |
---|---|
2310 """Represent the addition of two sets | 2310 """Represent the addition of two sets |
2311 | 2311 |
2312 Wrapper structure for lazily adding two structures without losing much | 2312 Wrapper structure for lazily adding two structures without losing much |
2313 performance on the __contains__ method | 2313 performance on the __contains__ method |
2314 | 2314 |
2315 If the ascending attribute is set, that means the two structures are | |
2316 ordered in either an ascending or descending way. Therefore, we can add | |
2317 them mantaining the order by iterating over both at the same time | |
2318 | |
2315 This class does not duck-type baseset and it's only supposed to be used | 2319 This class does not duck-type baseset and it's only supposed to be used |
2316 internally | 2320 internally |
2317 """ | 2321 """ |
2318 def __init__(self, revs1, revs2): | 2322 def __init__(self, revs1, revs2, ascending=None): |
2319 self._r1 = revs1 | 2323 self._r1 = revs1 |
2320 self._r2 = revs2 | 2324 self._r2 = revs2 |
2321 self._iter = None | 2325 self._iter = None |
2326 self._ascending = ascending | |
2322 | 2327 |
2323 def _iterator(self): | 2328 def _iterator(self): |
2324 if not self._iter: | 2329 if not self._iter: |
2325 def gen(): | 2330 def gen(): |
2326 for r in self._r1: | 2331 for r in self._r1: |