Mercurial > hg
changeset 20725:cf628b50afbb
revset: added isascending and isdescending methods to smartset classes
This methods state if the class is sorted in an ascending or descending order
We need this to implement methods based on order on smartset classes in order
to be able to create new objects with a given order.
We cannot just rely on a simple boolean since unordered set are neither
ascending nor descending.
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Tue, 11 Mar 2014 17:09:23 -0700 |
parents | e9a64b3f2925 |
children | 6eb9c4a9a12b |
files | mercurial/revset.py |
diffstat | 1 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Tue Mar 11 17:03:43 2014 -0700 +++ b/mercurial/revset.py Tue Mar 11 17:09:23 2014 -0700 @@ -2204,6 +2204,12 @@ l = [r for r in x if r not in s] return baseset(list(self) + l) + def isascending(self): + return False + + def isdescending(self): + return False + def filter(self, l): return lazyset(self, l) @@ -2270,6 +2276,12 @@ def set(self): return set([r for r in self]) + def isascending(self): + return False + + def isdescending(self): + return False + def filter(self, l): return lazyset(self, l) @@ -2309,6 +2321,12 @@ self._subset.sort(reverse=reverse) self._ascending = not reverse + def isascending(self): + return self._ascending + + def isdescending(self): + return not self._ascending + def reverse(self): self._subset.reverse() self._ascending = not self._ascending @@ -2621,6 +2639,12 @@ def set(self): return self + def isascending(self): + return self._start < self._end + + def isdescending(self): + return self._start > self._end + def filter(self, l): if self._start <= self._end: return orderedlazyset(self, l)