[PATCH 2 of 3] revset: added basic operations to spanset

Lucas Moscovicz lmoscovicz at fb.com
Wed Feb 12 15:54:50 CST 2014


# HG changeset patch
# User Lucas Moscovicz <lmoscovicz at fb.com>
# Date 1392229363 28800
#      Wed Feb 12 10:22:43 2014 -0800
# Node ID fd9f5172db9aef525229b9acebb1e892c280ed6e
# Parent  70cafa9cc41d0463146b3f746b119bf89cc1f80e
revset: added basic operations to spanset

Added methods __add__, __sub__ and __and__ to duck type more methods in
baseset

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2148,5 +2148,15 @@
         return (x <= self._start and x > self._end) or (x >= self._start and x<
                 self._end)
 
+    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(self)
+        return l + baseset(x)
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = symbols.values()


More information about the Mercurial-devel mailing list