[PATCH 3 of 4 RFC] revset: added __nonzero__ method to lazyset

Matt Mackall mpm at selenic.com
Fri Feb 21 14:38:23 CST 2014


On Fri, 2014-02-21 at 07:59 -0800, David Soria Parra wrote:
> On 02/20/2014 10:36 AM, Lucas Moscovicz wrote:
> > 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
> > +
> isn't this equivalent to
> def __nonzero__(self):
> 	return any(self)
> which should evaluate lazy and stop after the first element

Python 2.5.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list