generatorset: implement __nonzero__
authorPierre-Yves David <pierre-yves.david@fb.com>
Fri, 03 Oct 2014 01:56:57 -0500
changeset 22739 4ed47a1b2d24
parent 22738 70a0664008ea
child 22740 f40a57e8fda1
generatorset: implement __nonzero__ This is necessary to become a real smartset.
mercurial/revset.py
--- a/mercurial/revset.py	Fri Oct 03 00:31:33 2014 -0500
+++ b/mercurial/revset.py	Fri Oct 03 01:56:57 2014 -0500
@@ -2741,6 +2741,11 @@
         self._genlist = baseset([])
         self._finished = False
 
+    def __nonzero__(self):
+        for r in self:
+            return True
+        return False
+
     def __contains__(self, x):
         if x in self._cache:
             return self._cache[x]