Patchwork [6,of,9,RFC] revset: added basic operators to ordered lazysets

login
register
mail settings
Submitter Lucas Moscovicz
Date Feb. 12, 2014, 10:39 p.m.
Message ID <1cc650bf69c051609ef8.1392244796@dev1037.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3627/
State Superseded
Headers show

Comments

Lucas Moscovicz - Feb. 12, 2014, 10:39 p.m.
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz@fb.com>
# Date 1391737328 28800
#      Thu Feb 06 17:42:08 2014 -0800
# Node ID 1cc650bf69c051609ef85d955d7562cbf9285743
# Parent  1c8171087d53c930aee31fb53701bb1fb66341f0
revset: added basic operators to ordered lazysets

Now __add__ and __sub__ return ordered lazysets for both ascending and
descending lazysets.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2157,10 +2157,22 @@ 
     def filter(self, l):
         return asclazyset(self, l)
 
+    def __and__(self, x):
+        return asclazyset(self, lambda r: r in x)
+
+    def __sub__(self, x):
+        return asclazyset(self, lambda r: r not in x)
+
 class desclazyset(lazyset):
     def filter(self, l):
         return desclazyset(self, l)
 
+    def __and__(self, x):
+        return desclazyset(self, lambda r: r in x)
+
+    def __sub__(self, x):
+        return desclazyset(self, lambda r: r not in x)
+
 class generatorset(object):
     def __init__(self, gen):
         self._gen = gen