Patchwork [4,of,4] revset: added basic operators to orderedlazyset

login
register
mail settings
Submitter Lucas Moscovicz
Date Feb. 27, 2014, 10:12 p.m.
Message ID <079abbd960c16d19c29d.1393539171@dev1037.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3788/
State Superseded
Headers show

Comments

Lucas Moscovicz - Feb. 27, 2014, 10:12 p.m.
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz@fb.com>
# Date 1391737328 28800
#      Thu Feb 06 17:42:08 2014 -0800
# Node ID 079abbd960c16d19c29da248662ad7421bc75518
# Parent  f1f7558f3c3d6e4dc3b9342d86d98e4223f6c120
revset: added basic operators to orderedlazyset

Now __add__ and __sub__ return orderedlazyset.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2221,6 +2221,12 @@ 
     def filter(self, l):
         return orderedlazyset(self, l, self._order)
 
+    def __and__(self, x):
+        return orderedlazyset(self, lambda r: r in x, self._order)
+
+    def __sub__(self, x):
+        return orderedlazyset(self, lambda r: r not in x, self._order)
+
 class generatorset(object):
     """Wrapper structure for generators that provides lazy membership and can
     be iterated more than once.