revset: changed methods in spanset to return ordered sets
authorLucas Moscovicz <lmoscovicz@fb.com>
Tue, 18 Feb 2014 13:07:08 -0800
changeset 20659 4f68acdb22ff
parent 20658 d7e96dd8e995
child 20660 19e9478c1a22
revset: changed methods in spanset to return ordered sets Now __sub__ and __and__ can smartly return ordered lazysets.
mercurial/revset.py
--- 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():