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

Lucas Moscovicz lmoscovicz at fb.com
Fri Feb 21 18:35:47 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 c21e05d37daa1689935d83f10213f9faba4493ad
# Parent  857bff65281118fee59b3d636835409925cabafc
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
@@ -2143,6 +2149,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])
 
@@ -2279,5 +2289,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