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

login
register
mail settings
Submitter Lucas Moscovicz
Date Feb. 12, 2014, 9:54 p.m.
Message ID <fd9f5172db9aef525229.1392242090@dev1037.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3619/
State Accepted
Commit ed57358398af44184835e133e9530e6952f51be0
Headers show

Comments

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

Patch

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()