lazyset: inherit the fastasc and fastdesc method from subset
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 30 Sep 2014 23:36:57 -0500
changeset 22720 4388f99c5512
parent 22719 21fda9dcd4e8
child 22721 adc43967d401
lazyset: inherit the fastasc and fastdesc method from subset When the filtered subset has such methods, we can use them. It is implemented as properties to be able to quickly return None if no corresponding fastasc exists on the subset.
mercurial/revset.py
--- a/mercurial/revset.py	Thu Oct 02 18:25:37 2014 -0500
+++ b/mercurial/revset.py	Tue Sep 30 23:36:57 2014 -0500
@@ -2444,6 +2444,20 @@
             if cond(x):
                 yield x
 
+    @property
+    def fastasc(self):
+        it = self._subset.fastasc
+        if it is None:
+            return None
+        return lambda: self._iterfilter(it())
+
+    @property
+    def fastdesc(self):
+        it = self._subset.fastdesc
+        if it is None:
+            return None
+        return lambda: self._iterfilter(it())
+
     def __and__(self, x):
         return lazyset(self, x.__contains__)