# HG changeset patch # User Lucas Moscovicz # Date 2014-02-20 18:15:38 # Node ID 0e99a66eb7bcdb857c0079001df2039d79755782 # Parent efae655fd3635fec9e1730528a5fd5f220262652 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 @@ -2155,6 +2155,11 @@ class lazyset(object): 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])