Patchwork [10,of,10,py3] bundle2: use bytestr() instead of str() to convert part id to bytes

login
register
mail settings
Submitter Augie Fackler
Date Aug. 1, 2017, 8:34 p.m.
Message ID <d8907ce0da00480ddabf.1501619678@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/22618/
State Accepted
Headers show

Comments

Augie Fackler - Aug. 1, 2017, 8:34 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1500910120 14400
#      Mon Jul 24 11:28:40 2017 -0400
# Node ID d8907ce0da00480ddabfdf4214db1bc9cb1c75dd
# Parent  fab6234e619e0e57cec4b7d0b5150bfbbede8b30
bundle2: use bytestr() instead of str() to convert part id to bytes

This was exposed by trying to run previously-passing Python 3 tests.

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -468,7 +468,8 @@  def _processpart(op, part):
             if output:
                 outpart = op.reply.newpart('output', data=output,
                                            mandatory=False)
-                outpart.addparam('in-reply-to', str(part.id), mandatory=False)
+                outpart.addparam(
+                    'in-reply-to', pycompat.bytestr(part.id), mandatory=False)
     # If exiting or interrupted, do not attempt to seek the stream in the
     # finally block below. This makes abort faster.
     except (SystemExit, KeyboardInterrupt):
@@ -1556,7 +1557,8 @@  def handlechangegroup(op, inpart):
         # This is definitely not the final form of this
         # return. But one need to start somewhere.
         part = op.reply.newpart('reply:changegroup', mandatory=False)
-        part.addparam('in-reply-to', str(inpart.id), mandatory=False)
+        part.addparam(
+            'in-reply-to', pycompat.bytestr(inpart.id), mandatory=False)
         part.addparam('return', '%i' % ret, mandatory=False)
     assert not inpart.read()
 
@@ -1619,7 +1621,8 @@  def handleremotechangegroup(op, inpart):
         # This is definitely not the final form of this
         # return. But one need to start somewhere.
         part = op.reply.newpart('reply:changegroup')
-        part.addparam('in-reply-to', str(inpart.id), mandatory=False)
+        part.addparam(
+            'in-reply-to', pycompat.bytestr(inpart.id), mandatory=False)
         part.addparam('return', '%i' % ret, mandatory=False)
     try:
         real_part.validate()
@@ -1762,7 +1765,8 @@  def handlepushkey(op, inpart):
     op.records.add('pushkey', record)
     if op.reply is not None:
         rpart = op.reply.newpart('reply:pushkey')
-        rpart.addparam('in-reply-to', str(inpart.id), mandatory=False)
+        rpart.addparam(
+            'in-reply-to', pycompat.bytestr(inpart.id), mandatory=False)
         rpart.addparam('return', '%i' % ret, mandatory=False)
     if inpart.mandatory and not ret:
         kwargs = {}
@@ -1817,7 +1821,8 @@  def handleobsmarker(op, inpart):
     op.records.add('obsmarkers', {'new': new})
     if op.reply is not None:
         rpart = op.reply.newpart('reply:obsmarkers')
-        rpart.addparam('in-reply-to', str(inpart.id), mandatory=False)
+        rpart.addparam(
+            'in-reply-to', pycompat.bytestr(inpart.id), mandatory=False)
         rpart.addparam('new', '%i' % new, mandatory=False)