Mercurial > hg
changeset 20734:4d27c30d58d5
revset: changed smartset methods to return ordered addsets
Now when adding two structures that are ordered, they are wrapped into an
_addset and they get added lazily while keeping the order.
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Tue, 11 Mar 2014 17:25:53 -0700 |
parents | adf4ec7e6f60 |
children | 2115e035da11 |
files | mercurial/revset.py |
diffstat | 1 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Fri Mar 14 10:24:09 2014 -0700 +++ b/mercurial/revset.py Tue Mar 11 17:25:53 2014 -0700 @@ -2283,7 +2283,7 @@ return lazyset(self, lambda r: r not in x) def __add__(self, x): - return lazyset(_addset(self, x)) + return _addset(self, x) def __nonzero__(self): for r in self: @@ -2347,6 +2347,14 @@ return orderedlazyset(self, lambda r: r not in x, ascending=self._ascending) + def __add__(self, x): + kwargs = {} + if self.isascending() and x.isascending(): + kwargs['ascending'] = True + if self.isdescending() and x.isdescending(): + kwargs['ascending'] = False + return _addset(self, x, **kwargs) + def sort(self, reverse=False): if reverse: if self._ascending: @@ -2694,7 +2702,12 @@ return orderedlazyset(self, lambda r: r not in x, ascending=False) def __add__(self, x): - return lazyset(_addset(self, x)) + kwargs = {} + if self.isascending() and x.isascending(): + kwargs['ascending'] = True + if self.isdescending() and x.isdescending(): + kwargs['ascending'] = False + return _addset(self, x, **kwargs) def __len__(self): if not self._hiddenrevs: