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

login
register
mail settings
Submitter Lucas Moscovicz
Date Feb. 12, 2014, 10:39 p.m.
Message ID <020b11eeee89ad970bce.1392244794@dev1037.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3624/
State Superseded
Headers show

Comments

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

Patch

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