Patchwork [2,of,8,py3] bundles: turn nbchanges int into a bytestr using pycompat.bytestr

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

Comments

Augie Fackler - Sept. 15, 2017, 11:14 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1505515116 14400
#      Fri Sep 15 18:38:36 2017 -0400
# Node ID 43b1c3ab1d6a4af1ea86f4e9d676d52740782895
# Parent  662bbd6d96952985eff807f424dd128663724672
bundles: turn nbchanges int into a bytestr using pycompat.bytestr

Fixes some python 3 failures.
Yuya Nishihara - Sept. 16, 2017, 11:54 a.m.
On Fri, 15 Sep 2017 19:14:05 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <raf@durin42.com>
> # Date 1505515116 14400
> #      Fri Sep 15 18:38:36 2017 -0400
> # Node ID 43b1c3ab1d6a4af1ea86f4e9d676d52740782895
> # Parent  662bbd6d96952985eff807f424dd128663724672
> bundles: turn nbchanges int into a bytestr using pycompat.bytestr
> 
> Fixes some python 3 failures.
> 
> diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
> --- a/mercurial/bundle2.py
> +++ b/mercurial/bundle2.py
> @@ -1448,7 +1448,7 @@ def _addpartsfromopts(ui, repo, bundler,
>      part = bundler.newpart('changegroup', data=cg.getchunks())
>      part.addparam('version', cg.version)
>      if 'clcount' in cg.extras:
> -        part.addparam('nbchanges', str(cg.extras['clcount']),
> +        part.addparam('nbchanges', pycompat.bytestr(cg.extras['clcount']),

'%d' is preferred.
Augie Fackler - Sept. 16, 2017, 3:10 p.m.
> On Sep 16, 2017, at 7:54 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> On Fri, 15 Sep 2017 19:14:05 -0400, Augie Fackler wrote:
>> # HG changeset patch
>> # User Augie Fackler <raf@durin42.com>
>> # Date 1505515116 14400
>> #      Fri Sep 15 18:38:36 2017 -0400
>> # Node ID 43b1c3ab1d6a4af1ea86f4e9d676d52740782895
>> # Parent  662bbd6d96952985eff807f424dd128663724672
>> bundles: turn nbchanges int into a bytestr using pycompat.bytestr
>> 
>> Fixes some python 3 failures.
>> 
>> diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
>> --- a/mercurial/bundle2.py
>> +++ b/mercurial/bundle2.py
>> @@ -1448,7 +1448,7 @@ def _addpartsfromopts(ui, repo, bundler,
>>     part = bundler.newpart('changegroup', data=cg.getchunks())
>>     part.addparam('version', cg.version)
>>     if 'clcount' in cg.extras:
>> -        part.addparam('nbchanges', str(cg.extras['clcount']),
>> +        part.addparam('nbchanges', pycompat.bytestr(cg.extras['clcount']),
> 
> '%d' is preferred.

Some day I’ll remember. Thanks!

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1448,7 +1448,7 @@  def _addpartsfromopts(ui, repo, bundler,
     part = bundler.newpart('changegroup', data=cg.getchunks())
     part.addparam('version', cg.version)
     if 'clcount' in cg.extras:
-        part.addparam('nbchanges', str(cg.extras['clcount']),
+        part.addparam('nbchanges', pycompat.bytestr(cg.extras['clcount']),
                       mandatory=False)
     if opts.get('phases') and repo.revs('%ln and secret()',
                                         outgoing.missingheads):
@@ -1524,7 +1524,7 @@  def writebundle(ui, cg, filename, bundle
         part = bundle.newpart('changegroup', data=cg.getchunks())
         part.addparam('version', cg.version)
         if 'clcount' in cg.extras:
-            part.addparam('nbchanges', str(cg.extras['clcount']),
+            part.addparam('nbchanges', pycompat.bytestr(cg.extras['clcount']),
                           mandatory=False)
         chunkiter = bundle.getchunks()
     else:
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -423,7 +423,7 @@  def push(repo, remote, force=False, revs
     if opargs is None:
         opargs = {}
     pushop = pushoperation(repo, remote, force, revs, newbranch, bookmarks,
-                           **opargs)
+                           **pycompat.strkwargs(opargs))
     if pushop.remote.local():
         missing = (set(pushop.repo.requirements)
                    - pushop.remote.local().supported)
@@ -1640,7 +1640,8 @@  def _getbundlechangegrouppart(bundler, r
         part = bundler.newpart('changegroup', data=cgstream)
         if cgversions:
             part.addparam('version', version)
-        part.addparam('nbchanges', str(len(outgoing.missing)), mandatory=False)
+        part.addparam('nbchanges', pycompat.bytestr(len(outgoing.missing)),
+                      mandatory=False)
         if 'treemanifest' in repo.requirements:
             part.addparam('treemanifest', '1')