# HG changeset patch # User Lucas Moscovicz # Date 2014-03-12 00:25:53 # Node ID 4d27c30d58d5117027d887fe0c45257e928bbf42 # Parent adf4ec7e6f6025d18894fac246169302cc0e5d2e 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. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -2283,7 +2283,7 @@ class lazyset(object): 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 @@ class orderedlazyset(lazyset): 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 @@ class spanset(object): 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: