[PATCH 3 of 3] revset: changed methods in spanset to return ordered sets

Lucas Moscovicz lmoscovicz at fb.com
Fri Feb 28 17:27:51 CST 2014


# HG changeset patch
# User Lucas Moscovicz <lmoscovicz at fb.com>
# Date 1392757628 28800
#      Tue Feb 18 13:07:08 2014 -0800
# Node ID 320e4050c7b95213780f735dab11babc7aac2dcd
# Parent  b8f6b9ee7215fa4653cd35a623db4c493ea5714c
revset: changed methods in spanset to return ordered sets

Now __sub__ and __and__ can smartly return ordered lazysets.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2363,12 +2363,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):
         l = baseset(self)


More information about the Mercurial-devel mailing list