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.
--- 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