revset: added __nonzero__ method to lazyset
authorLucas Moscovicz <lmoscovicz@fb.com>
Thu, 20 Feb 2014 10:15:38 -0800
changeset 20552 0e99a66eb7bc
parent 20551 efae655fd363
child 20553 86cefb15e7b5
revset: added __nonzero__ method to lazyset Now it doesn't have to go through all the set and can return lazily as soon as it finds one element.
mercurial/revset.py
--- a/mercurial/revset.py	Wed Feb 12 15:30:27 2014 -0800
+++ b/mercurial/revset.py	Thu Feb 20 10:15:38 2014 -0800
@@ -2155,6 +2155,11 @@
         l = baseset([r for r in self])
         return l + baseset(x)
 
+    def __nonzero__(self):
+        for r in self:
+            return True
+        return False
+
     def __len__(self):
         # Basic implementation to be changed in future patches.
         l = baseset([r for r in self])