# HG changeset patch # User Steve Losh # Date 1266022749 18000 # Node ID e6dc4414723499cf63b3c7318900186b1c8fef8f # Parent 8a99388f87cc7368364513f74bae31f231e40127 util: add any() and all() functions for Python 2.4 compatibility This patch adds these two very useful functions to the mercurial.util module, because they are not present in Python 2.4. diff -r 8a99388f87cc -r e6dc44147234 mercurial/util.py --- a/mercurial/util.py Sat Feb 13 10:56:43 2010 +0100 +++ b/mercurial/util.py Fri Feb 12 19:59:09 2010 -0500 @@ -1342,3 +1342,15 @@ finally: if prevhandler is not None: signal.signal(signal.SIGCHLD, prevhandler) + +def any(iterable): + for i in iterable: + if i: + return True + return False + +def all(iterable): + for i in iterable: + if not i: + return False + return True