changeset 20428:2e33cda452f6

revset: added basic operations to lazyset Added methods __add__, __sub__ and __and__ to duck type more methods in baseset
author Lucas Moscovicz <lmoscovicz@fb.com>
date Thu, 06 Feb 2014 14:25:37 -0800
parents 4a9191ca848e
children f5b560c60bcd
files mercurial/revset.py
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Thu Feb 06 14:19:40 2014 -0800
+++ b/mercurial/revset.py	Thu Feb 06 14:25:37 2014 -0800
@@ -2090,5 +2090,15 @@
             if cond(x):
                 yield x
 
+    def __and__(self, x):
+        return lazyset(self, lambda r: r in x)
+
+    def __sub__(self, x):
+        return lazyset(self, lambda r: r not in x)
+
+    def __add__(self, x):
+        l = baseset([r for r in self])
+        return l + baseset(x)
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = symbols.values()