[PATCH 2 of 4 py3] maplist: replace instances of map() with pycompat.maplist() [2 of 4]

Pulkit Goyal 7895pulkit at gmail.com
Fri Mar 24 11:18:02 EDT 2017


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1490368062 -19800
#      Fri Mar 24 20:37:42 2017 +0530
# Node ID 1b471d88cab47d897afd5aa5ddda3031bd70a300
# Parent  35e6f3d8dbb1242c6cac1c64fd799db543e30444
maplist: replace instances of map() with pycompat.maplist() [2 of 4]

diff -r 35e6f3d8dbb1 -r 1b471d88cab4 mercurial/crecord.py
--- a/mercurial/crecord.py	Fri Mar 24 20:35:21 2017 +0530
+++ b/mercurial/crecord.py	Fri Mar 24 20:37:42 2017 +0530
@@ -20,6 +20,7 @@
     encoding,
     error,
     patch as patchmod,
+    pycompat,
     scmutil,
     util,
 )
@@ -494,7 +495,8 @@
     chunkselector = curseschunkselector(headerlist, ui, operation)
     if testfn and os.path.exists(testfn):
         testf = open(testfn)
-        testcommands = map(lambda x: x.rstrip('\n'), testf.readlines())
+        testcommands = pycompat.maplist(lambda x: x.rstrip('\n'),
+                        testf.readlines())
         testf.close()
         while True:
             if chunkselector.handlekeypressed(testcommands.pop(0), test=True):
diff -r 35e6f3d8dbb1 -r 1b471d88cab4 mercurial/dagutil.py
--- a/mercurial/dagutil.py	Fri Mar 24 20:35:21 2017 +0530
+++ b/mercurial/dagutil.py	Fri Mar 24 20:37:42 2017 +0530
@@ -10,6 +10,7 @@
 
 from .i18n import _
 from .node import nullrev
+from . import pycompat
 
 class basedag(object):
     '''generic interface for DAGs
@@ -144,11 +145,11 @@
     def _internalizeall(self, ids, filterunknown):
         rl = self._revlog
         if filterunknown:
-            return [r for r in map(rl.nodemap.get, ids)
+            return [r for r in pycompat.maplist(rl.nodemap.get, ids)
                     if (r is not None
                         and r != nullrev
                         and r not in rl.filteredrevs)]
-        return map(self._internalize, ids)
+        return pycompat.maplist(self._internalize, ids)
 
 
 class revlogdag(revlogbaseddag):
diff -r 35e6f3d8dbb1 -r 1b471d88cab4 mercurial/dispatch.py
--- a/mercurial/dispatch.py	Fri Mar 24 20:35:21 2017 +0530
+++ b/mercurial/dispatch.py	Fri Mar 24 20:37:42 2017 +0530
@@ -280,7 +280,7 @@
 def aliasargs(fn, givenargs):
     args = getattr(fn, 'args', [])
     if args:
-        cmd = ' '.join(map(util.shellquote, args))
+        cmd = ' '.join(pycompat.maplist(util.shellquote, args))
 
         nums = []
         def replacer(m):
@@ -402,7 +402,7 @@
 
     @property
     def args(self):
-        args = map(util.expandpath, self.givenargs)
+        args = pycompat.maplist(util.expandpath, self.givenargs)
         return aliasargs(self.fn, args)
 
     def __getattr__(self, name):
@@ -815,7 +815,7 @@
                     if not func.optionalrepo:
                         if func.inferrepo and args and not path:
                             # try to infer -R from command args
-                            repos = map(cmdutil.findrepo, args)
+                            repos = pycompat.maplist(cmdutil.findrepo, args)
                             guess = repos[0]
                             if guess and repos.count(guess) == len(repos):
                                 req.args = ['--repository', guess] + fullargs
diff -r 35e6f3d8dbb1 -r 1b471d88cab4 mercurial/revlog.py
--- a/mercurial/revlog.py	Fri Mar 24 20:35:21 2017 +0530
+++ b/mercurial/revlog.py	Fri Mar 24 20:37:42 2017 +0530
@@ -963,7 +963,7 @@
             ancs = ancestor.ancestors(self.parentrevs, a, b)
         if ancs:
             # choose a consistent winner when there's a tie
-            return min(map(self.node, ancs))
+            return min(pycompat.maplist(self.node, ancs))
         return nullid
 
     def _match(self, id):
diff -r 35e6f3d8dbb1 -r 1b471d88cab4 mercurial/revsetlang.py
--- a/mercurial/revsetlang.py	Fri Mar 24 20:35:21 2017 +0530
+++ b/mercurial/revsetlang.py	Fri Mar 24 20:37:42 2017 +0530
@@ -52,7 +52,7 @@
 _syminitletters = set(pycompat.iterbytestr(
     string.ascii_letters.encode('ascii') +
     string.digits.encode('ascii') +
-    '._@')) | set(map(pycompat.bytechr, xrange(128, 256)))
+    '._@')) | set(pycompat.maplist(pycompat.bytechr, xrange(128, 256)))
 
 # default set of valid characters for non-initial letters of symbols
 _symletters = _syminitletters | set(pycompat.iterbytestr('-/'))
@@ -674,7 +674,7 @@
 
 def depth(tree):
     if isinstance(tree, tuple):
-        return max(map(depth, tree)) + 1
+        return max(pycompat.maplist(depth, tree)) + 1
     else:
         return 0
 
diff -r 35e6f3d8dbb1 -r 1b471d88cab4 mercurial/treediscovery.py
--- a/mercurial/treediscovery.py	Fri Mar 24 20:35:21 2017 +0530
+++ b/mercurial/treediscovery.py	Fri Mar 24 20:37:42 2017 +0530
@@ -16,6 +16,7 @@
 )
 from . import (
     error,
+    pycompat,
 )
 
 def findcommonincoming(repo, remote, heads=None, force=False):
@@ -105,7 +106,7 @@
             reqcnt += 1
             repo.ui.progress(_('searching'), reqcnt, unit=_('queries'))
             repo.ui.debug("request %d: %s\n" %
-                        (reqcnt, " ".join(map(short, r))))
+                        (reqcnt, " ".join(pycompat.maplist(short, r))))
             for p in xrange(0, len(r), 10):
                 for b in remote.branches(r[p:p + 10]):
                     repo.ui.debug("received %s:%s\n" %


More information about the Mercurial-devel mailing list