[PATCH 4 of 9 RFC] revset: added filter method to revset classes

Lucas Moscovicz lmoscovicz at fb.com
Wed Feb 12 16:39:54 CST 2014


# HG changeset patch
# User Lucas Moscovicz <lmoscovicz at fb.com>
# Date 1391735891 28800
#      Thu Feb 06 17:18:11 2014 -0800
# Node ID 020b11eeee89ad970bce64312232325428b1d3b1
# Parent  c75f012c0929a57395a0a6b7a38d1ac865262943
revset: added filter method to revset classes

This method will replace the creation of lazysets inside the revset methods.
Instead, the classes that handle lazy structures will create them based on
their current order.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2092,6 +2092,9 @@
         l = [r for r in x if r not in s]
         return baseset(list(self) + l)
 
+    def filter(self, l):
+        return lazyset(self, l)
+
 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
@@ -2147,11 +2150,16 @@
     def set(self):
         return set([r for r in self])
 
+    def filter(self, l):
+        return lazyset(self, l)
+
 class asclazyset(lazyset):
-    pass
+    def filter(self, l):
+        return asclazyset(self, l)
 
 class desclazyset(lazyset):
-    pass
+    def filter(self, l):
+        return desclazyset(self, l)
 
 class generatorset(object):
     def __init__(self, gen):
@@ -2298,5 +2306,11 @@
     def set(self):
         return self
 
+    def filter(self, l):
+        if self._start <= self._end:
+            return asclazyset(self, l)
+        else:
+            return desclazyset(self, l)
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = symbols.values()


More information about the Mercurial-devel mailing list