[PATCH 1 of 1] util: remove any() and all()

Steve Losh steve at stevelosh.com
Sun Jul 4 11:24:20 CDT 2010


# HG changeset patch
# User Steve Losh <steve at stevelosh.com>
# Date 1278260368 14400
# Node ID 7d5b074200e8ea87a69d38d2cf6fe274c4853023
# Parent  96040c70c9e1fad7daa011f415d04da7d1fec273
util: remove any() and all()

Now that Python 2.7 has been released the three latest versions of Python are
2.5, 2.6 and 2.7, all of which have these functions built in.

diff --git a/hgext/gpg.py b/hgext/gpg.py
--- a/hgext/gpg.py
+++ b/hgext/gpg.py
@@ -237,11 +237,11 @@
         repo.opener("localsigs", "ab").write(sigmessage)
         return
 
     msigs = match.exact(repo.root, '', ['.hgsigs'])
     s = repo.status(match=msigs, unknown=True, ignored=True)[:6]
-    if util.any(s) and not opts["force"]:
+    if any(s) and not opts["force"]:
         raise util.Abort(_("working copy of .hgsigs is changed "
                            "(please commit .hgsigs manually "
                            "or use --force)"))
 
     repo.wfile(".hgsigs", "ab").write(sigmessage)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -202,11 +202,11 @@
             'tgz': ['.tgz', '.tar.gz'],
             'zip': ['.zip'],
         }
 
         for type, extensions in exttypes.items():
-            if util.any(dest.endswith(ext) for ext in extensions):
+            if any(dest.endswith(ext) for ext in extensions):
                 return type
         return None
 
     kind = opts.get('type') or guess_type() or 'files'
     prefix = opts.get('prefix')
@@ -2121,11 +2121,11 @@
     elif not rev:
         ctx = repo[None]
         parents = ctx.parents()
         changed = False
         if default or id or num:
-            changed = util.any(repo.status())
+            changed = any(repo.status())
         if default or id:
             output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]),
                                 (changed) and "+" or "")]
         if num:
             output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]),
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1364,25 +1364,10 @@
         return pid
     finally:
         if prevhandler is not None:
             signal.signal(signal.SIGCHLD, prevhandler)
 
-try:
-    any, all = any, all
-except NameError:
-    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
-
 def termwidth():
     if 'COLUMNS' in os.environ:
         try:
             return int(os.environ['COLUMNS'])
         except ValueError:


More information about the Mercurial-devel mailing list