Patchwork D3123: py3: use list comprehension instead of map()

login
register
mail settings
Submitter phabricator
Date April 5, 2018, 12:30 p.m.
Message ID <differential-rev-PHID-DREV-p66b45ioio22jhme5nw2-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/30350/
State Superseded
Headers show

Comments

phabricator - April 5, 2018, 12:30 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  map() on Python 3 returns a map object not a list, so let's use list
  comprehension where we require list.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3123

AFFECTED FILES
  hgext/journal.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - April 5, 2018, 1:43 p.m.
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  That shouldn't matter here because bytes.join() takes an iterable.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3123

To: pulkit, #hg-reviewers, yuja
Cc: yuja, mercurial-devel

Patch

diff --git a/hgext/journal.py b/hgext/journal.py
--- a/hgext/journal.py
+++ b/hgext/journal.py
@@ -226,7 +226,7 @@ 
 
     def __bytes__(self):
         """bytes representation for storage"""
-        time = ' '.join(map(pycompat.bytestr, self.timestamp))
+        time = ' '.join([pycompat.bytestr(a) for a in self.timestamp])
         oldhashes = ','.join([node.hex(hash) for hash in self.oldhashes])
         newhashes = ','.join([node.hex(hash) for hash in self.newhashes])
         return '\n'.join((
@@ -273,7 +273,7 @@ 
     @property
     def command(self):
         commandstr = ' '.join(
-            map(procutil.shellquote, journalstorage._currentcommand))
+            [procutil.shellquote(a) for a in journalstorage._currentcommand])
         if '\n' in commandstr:
             # truncate multi-line commands
             commandstr = commandstr.partition('\n')[0] + ' ...'