Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revset.py @ 20729:caa69cb223b0
revset: added ascending and descending methods to _addset
This methods are intended to duck-type baseset, so we will still have _addset
as a private class but will be able return it without wrapping it into an
orderedlazyset or a lazyset.
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Fri, 14 Mar 2014 10:21:56 -0700 |
parents | 1c8b62c0a47e |
children | 180d47e1fb68 |
comparison
equal
deleted
inserted
replaced
20728:1c8b62c0a47e | 20729:caa69cb223b0 |
---|---|
2395 def filter(self, condition): | 2395 def filter(self, condition): |
2396 if self._ascending is not None: | 2396 if self._ascending is not None: |
2397 return orderedlazyset(self, condition, ascending=self._ascending) | 2397 return orderedlazyset(self, condition, ascending=self._ascending) |
2398 return lazyset(self, condition) | 2398 return lazyset(self, condition) |
2399 | 2399 |
2400 def ascending(self): | |
2401 if self._ascending is None: | |
2402 self.sort() | |
2403 self._ascending = True | |
2404 else: | |
2405 if not self._ascending: | |
2406 self.reverse() | |
2407 | |
2408 def descending(self): | |
2409 if self._ascending is None: | |
2410 self.sort(reverse=True) | |
2411 self._ascending = False | |
2412 else: | |
2413 if self._ascending: | |
2414 self.reverse() | |
2415 | |
2400 def _iterator(self): | 2416 def _iterator(self): |
2401 """Iterate over both collections without repeating elements | 2417 """Iterate over both collections without repeating elements |
2402 | 2418 |
2403 If the ascending attribute is not set, iterate over the first one and | 2419 If the ascending attribute is not set, iterate over the first one and |
2404 then over the second one checking for membership on the first one so we | 2420 then over the second one checking for membership on the first one so we |