changeset 20552:0e99a66eb7bc

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.
author Lucas Moscovicz <lmoscovicz@fb.com>
date Thu, 20 Feb 2014 10:15:38 -0800
parents efae655fd363
children 86cefb15e7b5
files mercurial/revset.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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])