Patchwork [06,of,10,py3] mpatch: use bytesio instead of stringio in pure-python mpatch code

login
register
mail settings
Submitter Augie Fackler
Date March 12, 2017, 6:57 p.m.
Message ID <30c4b444e0beaea64ab3.1489345066@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/19208/
State Accepted
Headers show

Comments

Augie Fackler - March 12, 2017, 6:57 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1489297542 18000
#      Sun Mar 12 00:45:42 2017 -0500
# Node ID 30c4b444e0beaea64ab35b594bb976bafba9aa34
# Parent  666d6b8778093c73611aa728f92c688a75994ed6
mpatch: use bytesio instead of stringio in pure-python mpatch code
Yuya Nishihara - March 12, 2017, 7:15 p.m.
On Sun, 12 Mar 2017 14:57:46 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1489297542 18000
> #      Sun Mar 12 00:45:42 2017 -0500
> # Node ID 30c4b444e0beaea64ab35b594bb976bafba9aa34
> # Parent  666d6b8778093c73611aa728f92c688a75994ed6
> mpatch: use bytesio instead of stringio in pure-python mpatch code
> 
> diff --git a/mercurial/pure/mpatch.py b/mercurial/pure/mpatch.py
> --- a/mercurial/pure/mpatch.py
> +++ b/mercurial/pure/mpatch.py
> @@ -7,10 +7,10 @@
>  
>  from __future__ import absolute_import
>  
> +import io
>  import struct
>  
> -from . import policy, pycompat
> -stringio = pycompat.stringio
> +from . import policy
>  modulepolicy = policy.policy
>  policynocffi = policy.policynocffi
>  
> @@ -68,7 +68,7 @@ def patches(a, bins):
>      if not tl:
>          return a
>  
> -    m = stringio()
> +    m = io.BytesIO()

Perhaps this is the bug of our pycompat layer, which should export BytesIO
as stringio on Python 3.

Queued the other patches, thanks.

Patch

diff --git a/mercurial/pure/mpatch.py b/mercurial/pure/mpatch.py
--- a/mercurial/pure/mpatch.py
+++ b/mercurial/pure/mpatch.py
@@ -7,10 +7,10 @@ 
 
 from __future__ import absolute_import
 
+import io
 import struct
 
-from . import policy, pycompat
-stringio = pycompat.stringio
+from . import policy
 modulepolicy = policy.policy
 policynocffi = policy.policynocffi
 
@@ -68,7 +68,7 @@  def patches(a, bins):
     if not tl:
         return a
 
-    m = stringio()
+    m = io.BytesIO()
 
     # load our original text
     m.write(a)
@@ -167,4 +167,3 @@  if modulepolicy not in policynocffi:
             res = ffi.buffer(buf, outlen)[:]
             lib.mpatch_lfree(patch)
             return res
-