Patchwork [5,of,7] exchange: use pycompat.bytestr() instead of str() to encode ints

login
register
mail settings
Submitter Augie Fackler
Date Aug. 29, 2017, 3:22 p.m.
Message ID <8d65029a473f6ff1b1fd.1504020122@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/23475/
State Accepted
Headers show

Comments

Augie Fackler - Aug. 29, 2017, 3:22 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1503451273 14400
#      Tue Aug 22 21:21:13 2017 -0400
# Node ID 8d65029a473f6ff1b1fde49403dd467caf3fd1c0
# Parent  26ac215809cffdee88cb32e13e2728f6830e0d84
exchange: use pycompat.bytestr() instead of str() to encode ints
Yuya Nishihara - Aug. 31, 2017, 1:57 p.m.
On Tue, 29 Aug 2017 11:22:02 -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 8d65029a473f6ff1b1fde49403dd467caf3fd1c0
> # Parent  26ac215809cffdee88cb32e13e2728f6830e0d84
> exchange: use pycompat.bytestr() instead of str() to encode ints
> 
> diff --git a/mercurial/exchange.py b/mercurial/exchange.py
> --- a/mercurial/exchange.py
> +++ b/mercurial/exchange.py
> @@ -792,8 +792,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(pycompat.bytestr(phases.draft)))
> +        part.addparam('new', enc(pycompat.bytestr(phases.public)))

'%d' is preferable here.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -792,8 +792,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(pycompat.bytestr(phases.draft)))
+        part.addparam('new', enc(pycompat.bytestr(phases.public)))
         part2node.append((part.id, newremotehead))
         pushop.pkfailcb[part.id] = handlefailure