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

login
register
mail settings
Submitter Lucas Moscovicz
Date Feb. 28, 2014, 11:27 p.m.
Message ID <320e4050c7b95213780f.1393630071@dev1037.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3811/
State Accepted
Commit 4f68acdb22ff89f5a1990aaed4321c4931109c2a
Headers show

Comments

Lucas Moscovicz - Feb. 28, 2014, 11:27 p.m.
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz@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.

Patch

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)