[PATCH 2 of 4 RFC] revset: implemented discard method on lazy classes

Lucas Moscovicz lmoscovicz at fb.com
Thu Feb 20 12:36:31 CST 2014


# HG changeset patch
# User Lucas Moscovicz <lmoscovicz at fb.com>
# Date 1392395021 28800
#      Fri Feb 14 08:23:41 2014 -0800
# Node ID 20cac5a92843ff52c2c4d0af45505cf9a303086b
# Parent  91b77bbaa0970724742e9d2700e1123403b9d386
revset: implemented discard method on lazy classes

Implemented this method to duck type set when used in cmdutil.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2093,6 +2093,12 @@
         l = [r for r in x if r not in s]
         return baseset(list(self) + l)
 
+    def discard(self, x):
+        if x in self:
+            self.remove(x)
+        if self._set:
+            self._set.discard(x)
+
 class lazyset(object):
     """Duck type for baseset class which iterates lazily over the revisions in
     the subset and contains a function which tests for membership in the
@@ -2155,6 +2161,10 @@
     def reverse(self):
         self._subset.reverse()
 
+    def discard(self, x):
+        self._subset.discard(x)
+        self._cache[x] = False
+
     def set(self):
         return set([r for r in self])
 
@@ -2299,5 +2309,8 @@
     def set(self):
         return self
 
+    def discard(self, x):
+        self._hiddenrevs.add(x)
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = symbols.values()


More information about the Mercurial-devel mailing list