[PATCH 3 of 4 RFC] revset: added __nonzero__ method to lazyset
Lucas Moscovicz
lmoscovicz at fb.com
Thu Feb 20 12:36:32 CST 2014
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz at fb.com>
# Date 1392920138 28800
# Thu Feb 20 10:15:38 2014 -0800
# Node ID 44ca956d656db4e57add5e815dfd0aaaec57c6b9
# Parent 20cac5a92843ff52c2c4d0af45505cf9a303086b
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.
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2143,6 +2143,11 @@
def extend(self, x):
self.append(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])
More information about the Mercurial-devel
mailing list