diff mercurial/util.py @ 10438:e6dc44147234

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.
author Steve Losh <steve@stevelosh.com>
date Fri, 12 Feb 2010 19:59:09 -0500
parents 600142e7a028
children 7a6b5f85c3ab
line wrap: on
line diff
--- 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