Patchwork [3,of,8,py3] exchange: use '%d' % x instead of str(x) to encode ints

login
register
mail settings
Submitter Augie Fackler
Date Sept. 15, 2017, 11:14 p.m.
Message ID <e6d61e2a38873be057c9.1505517246@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/23923/
State Accepted
Headers show

Comments

Augie Fackler - Sept. 15, 2017, 11:14 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1503451273 14400
#      Tue Aug 22 21:21:13 2017 -0400
# Node ID e6d61e2a38873be057c9ecd0432750935423d745
# Parent  43b1c3ab1d6a4af1ea86f4e9d676d52740782895
exchange: use '%d' % x instead of str(x) to encode ints

Recommended by Yuya instead of using pycompat.bytestr() in this case.
Yuya Nishihara - Sept. 16, 2017, 11:55 a.m.
On Fri, 15 Sep 2017 19:14:06 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <raf@durin42.com>
> # Date 1503451273 14400
> #      Tue Aug 22 21:21:13 2017 -0400
> # Node ID e6d61e2a38873be057c9ecd0432750935423d745
> # Parent  43b1c3ab1d6a4af1ea86f4e9d676d52740782895
> exchange: use '%d' % x instead of str(x) to encode ints

Queued this, thanks.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -791,8 +791,8 @@  def _pushb2phases(pushop, bundler):
         part = bundler.newpart('pushkey')
         part.addparam('namespace', enc('phases'))
         part.addparam('key', enc(newremotehead.hex()))
-        part.addparam('old', enc(str(phases.draft)))
-        part.addparam('new', enc(str(phases.public)))
+        part.addparam('old', enc('%d' % phases.draft))
+        part.addparam('new', enc('%d' % phases.public))
         part2node.append((part.id, newremotehead))
         pushop.pkfailcb[part.id] = handlefailure