Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 22751:e76aec3eddc4
orderedlazyset: drop this now unused class
All my friends are dead.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 03 Oct 2014 01:44:52 -0500 |
parents | 66e2b648deef |
children | 7bbc35c43bff |
comparison
equal
deleted
inserted
replaced
22750:66e2b648deef | 22751:e76aec3eddc4 |
---|---|
2498 return self._ascending is not None and self._ascending | 2498 return self._ascending is not None and self._ascending |
2499 | 2499 |
2500 def isdescending(self): | 2500 def isdescending(self): |
2501 return self._ascending is not None and not self._ascending | 2501 return self._ascending is not None and not self._ascending |
2502 | 2502 |
2503 class orderedlazyset(_orderedsetmixin, filteredset): | |
2504 """Subclass of filteredset which subset can be ordered either ascending or | |
2505 descendingly | |
2506 """ | |
2507 def __init__(self, subset, condition, ascending=True): | |
2508 super(orderedlazyset, self).__init__(subset, condition) | |
2509 self._ascending = ascending | |
2510 | |
2511 def filter(self, l): | |
2512 return orderedlazyset(self, l, ascending=self._ascending) | |
2513 | |
2514 def ascending(self): | |
2515 if not self._ascending: | |
2516 self.reverse() | |
2517 | |
2518 def descending(self): | |
2519 if self._ascending: | |
2520 self.reverse() | |
2521 | |
2522 def __and__(self, x): | |
2523 return orderedlazyset(self, x.__contains__, | |
2524 ascending=self._ascending) | |
2525 | |
2526 def __sub__(self, x): | |
2527 return orderedlazyset(self, lambda r: r not in x, | |
2528 ascending=self._ascending) | |
2529 | |
2530 def __add__(self, x): | |
2531 kwargs = {} | |
2532 if self.isascending() and x.isascending(): | |
2533 kwargs['ascending'] = True | |
2534 if self.isdescending() and x.isdescending(): | |
2535 kwargs['ascending'] = False | |
2536 return _addset(self, x, **kwargs) | |
2537 | |
2538 def sort(self, reverse=False): | |
2539 if reverse: | |
2540 if self._ascending: | |
2541 self._subset.sort(reverse=reverse) | |
2542 else: | |
2543 if not self._ascending: | |
2544 self._subset.sort(reverse=reverse) | |
2545 self._ascending = not reverse | |
2546 | |
2547 def isascending(self): | |
2548 return self._ascending | |
2549 | |
2550 def isdescending(self): | |
2551 return not self._ascending | |
2552 | |
2553 def reverse(self): | |
2554 self._subset.reverse() | |
2555 self._ascending = not self._ascending | |
2556 | |
2557 class _addset(abstractsmartset): | 2503 class _addset(abstractsmartset): |
2558 """Represent the addition of two sets | 2504 """Represent the addition of two sets |
2559 | 2505 |
2560 Wrapper structure for lazily adding two structures without losing much | 2506 Wrapper structure for lazily adding two structures without losing much |
2561 performance on the __contains__ method | 2507 performance on the __contains__ method |