changeset 20659:4f68acdb22ff

revset: changed methods in spanset to return ordered sets Now __sub__ and __and__ can smartly return ordered lazysets.
author Lucas Moscovicz <lmoscovicz@fb.com>
date Tue, 18 Feb 2014 13:07:08 -0800
parents d7e96dd8e995
children 19e9478c1a22
files mercurial/revset.py
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Tue Feb 25 10:36:23 2014 -0800
+++ b/mercurial/revset.py	Tue Feb 18 13:07:08 2014 -0800
@@ -2409,12 +2409,18 @@
     def __and__(self, x):
         if isinstance(x, baseset):
             x = x.set()
-        return lazyset(self, lambda r: r in x)
+        if self._start <= self._end:
+            return orderedlazyset(self, lambda r: r in x)
+        else:
+            return orderedlazyset(self, lambda r: r in x, ascending=False)
 
     def __sub__(self, x):
         if isinstance(x, baseset):
             x = x.set()
-        return lazyset(self, lambda r: r not in x)
+        if self._start <= self._end:
+            return orderedlazyset(self, lambda r: r not in x)
+        else:
+            return orderedlazyset(self, lambda r: r not in x, ascending=False)
 
     def __add__(self, x):
         def iterates():