Patchwork [1,of,9] py3: use "%d" % val for int rather than pycompat.bytestr

login
register
mail settings
Submitter Pulkit Goyal
Date June 23, 2017, 7:54 p.m.
Message ID <8dce5f597161758063af.1498247695@workspace>
Download mbox | patch
Permalink /patch/21644/
State Accepted
Headers show

Comments

Pulkit Goyal - June 23, 2017, 7:54 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1498075147 -19800
#      Thu Jun 22 01:29:07 2017 +0530
# Node ID 8dce5f597161758063af4d58068f484f633afb85
# Parent  1c97df5e3b46d1b8dc3e0df3ae07b35c55c0db68
py3: use "%d" % val for int rather than pycompat.bytestr

Earlier I used pycompat.bytestr() to convert integers to bytes, but we can do
b"%d" % val to convert that int to bytes. b'' is already added by the
transformer.

Thanks to Yuya for suggesting this.
Yuya Nishihara - June 24, 2017, 3:31 a.m.
On Sat, 24 Jun 2017 01:24:55 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1498075147 -19800
> #      Thu Jun 22 01:29:07 2017 +0530
> # Node ID 8dce5f597161758063af4d58068f484f633afb85
> # Parent  1c97df5e3b46d1b8dc3e0df3ae07b35c55c0db68
> py3: use "%d" % val for int rather than pycompat.bytestr

Queued 1-5, 7, and 8, thanks.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2845,8 +2845,7 @@ 
                   ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
             if num:
                 output.append("%s%s" %
-                  ('+'.join([pycompat.bytestr(p.rev()) for p in parents]),
-                                                                    changed))
+                  ('+'.join(["%d" % p.rev() for p in parents]), changed))
         else:
             if default or id:
                 output = [hexfunc(ctx.node())]
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -623,7 +623,7 @@ 
     ctx = args['ctx']
     pctxs = scmutil.meaningfulparents(repo, ctx)
     # ifcontains() needs a list of str
-    prevs = [pycompat.bytestr(p.rev()) for p in pctxs]
+    prevs = ["%d" % p.rev() for p in pctxs]
     parents = [[('rev', p.rev()),
                 ('node', p.hex()),
                 ('phase', p.phasestr())]
@@ -653,7 +653,7 @@ 
     args = pycompat.byteskwargs(args)
     repo = args['ctx'].repo()
     # ifcontains() needs a list of str
-    revs = [pycompat.bytestr(r) for r in revs]
+    revs = ["%d" % r for r in revs]
     f = _showlist(name, revs, args)
     return _hybrid(f, revs,
                    lambda x: {name: x, 'ctx': repo[int(x)], 'revcache': {}},