Patchwork [2,of,4] py3: byte-stringify literals in extension in test-bundle2-remote-changegroup.t

login
register
mail settings
Submitter Yuya Nishihara
Date July 12, 2018, 2:17 p.m.
Message ID <e934284b4390484eb576.1531405048@mimosa>
Download mbox | patch
Permalink /patch/32815/
State Accepted
Headers show

Comments

Yuya Nishihara - July 12, 2018, 2:17 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1531046351 -32400
#      Sun Jul 08 19:39:11 2018 +0900
# Node ID e934284b4390484eb576a1e9275bf7c97a758d04
# Parent  fe6ac85bbf77ebebec9d0030549f7e1ae525f4b2
py3: byte-stringify literals in extension in test-bundle2-remote-changegroup.t

# skip-blame just some b''

Patch

diff --git a/tests/test-bundle2-remote-changegroup.t b/tests/test-bundle2-remote-changegroup.t
--- a/tests/test-bundle2-remote-changegroup.t
+++ b/tests/test-bundle2-remote-changegroup.t
@@ -40,45 +40,45 @@  Create an extension to test bundle2 remo
   >           Python expression as parameters. The Python expression is
   >           evaluated with eval, and is expected to be a dict.
   >     """
-  >     def newpart(name, data=''):
+  >     def newpart(name, data=b''):
   >         """wrapper around bundler.newpart adding an extra part making the
   >         client output information about each processed part"""
-  >         bundler.newpart('output', data=name)
+  >         bundler.newpart(b'output', data=name)
   >         part = bundler.newpart(name, data=data)
   >         return part
   > 
-  >     for line in open(repo.vfs.join('bundle2maker'), 'rb'):
+  >     for line in open(repo.vfs.join(b'bundle2maker'), 'rb'):
   >         line = line.strip()
   >         try:
   >             verb, args = line.split(None, 1)
   >         except ValueError:
-  >             verb, args = line, ''
-  >         if verb == 'remote-changegroup':
+  >             verb, args = line, b''
+  >         if verb == b'remote-changegroup':
   >            url, file = args.split()
   >            bundledata = open(file, 'rb').read()
-  >            digest = util.digester.preferred(b2caps['digests'])
+  >            digest = util.digester.preferred(b2caps[b'digests'])
   >            d = util.digester([digest], bundledata)
-  >            part = newpart('remote-changegroup')
-  >            part.addparam('url', url)
-  >            part.addparam('size', str(len(bundledata)))
-  >            part.addparam('digests', digest)
-  >            part.addparam('digest:%s' % digest, d[digest])
-  >         elif verb == 'raw-remote-changegroup':
-  >            part = newpart('remote-changegroup')
+  >            part = newpart(b'remote-changegroup')
+  >            part.addparam(b'url', url)
+  >            part.addparam(b'size', str(len(bundledata)))
+  >            part.addparam(b'digests', digest)
+  >            part.addparam(b'digest:%s' % digest, d[digest])
+  >         elif verb == b'raw-remote-changegroup':
+  >            part = newpart(b'remote-changegroup')
   >            for k, v in eval(args).items():
   >                part.addparam(k, str(v))
-  >         elif verb == 'changegroup':
+  >         elif verb == b'changegroup':
   >             _common, heads = args.split()
   >             common.extend(repo[r].node() for r in repo.revs(_common))
   >             heads = [repo[r].node() for r in repo.revs(heads)]
   >             outgoing = discovery.outgoing(repo, common, heads)
-  >             cg = changegroup.makechangegroup(repo, outgoing, '01',
-  >                                              'changegroup')
-  >             newpart('changegroup', cg.getchunks())
+  >             cg = changegroup.makechangegroup(repo, outgoing, b'01',
+  >                                              b'changegroup')
+  >             newpart(b'changegroup', cg.getchunks())
   >         else:
   >             raise Exception('unknown verb')
   > 
-  > exchange.getbundle2partsmapping['changegroup'] = _getbundlechangegrouppart
+  > exchange.getbundle2partsmapping[b'changegroup'] = _getbundlechangegrouppart
   > EOF
 
 Start a simple HTTP server to serve bundles