py3: open files in bytes mode in transplant.py
authorPulkit Goyal <7895pulkit@gmail.com>
Wed, 14 Feb 2018 17:39:56 +0530
changeset 36187 a9d1ac7b91a8
parent 36186 c1628a5eac87
child 36188 4e33aa8639d0
py3: open files in bytes mode in transplant.py Differential Revision: https://phab.mercurial-scm.org/D2265
hgext/transplant.py
--- a/hgext/transplant.py	Wed Feb 14 17:06:20 2018 +0530
+++ b/hgext/transplant.py	Wed Feb 14 17:39:56 2018 +0530
@@ -211,7 +211,7 @@
                     patchfile = None
                 else:
                     fd, patchfile = tempfile.mkstemp(prefix='hg-transplant-')
-                    fp = os.fdopen(fd, pycompat.sysstr('w'))
+                    fp = os.fdopen(fd, pycompat.sysstr('wb'))
                     gen = patch.diff(source, parent, node, opts=diffopts)
                     for chunk in gen:
                         fp.write(chunk)
@@ -259,7 +259,7 @@
         self.ui.status(_('filtering %s\n') % patchfile)
         user, date, msg = (changelog[1], changelog[2], changelog[4])
         fd, headerfile = tempfile.mkstemp(prefix='hg-transplant-')
-        fp = os.fdopen(fd, pycompat.sysstr('w'))
+        fp = os.fdopen(fd, pycompat.sysstr('wb'))
         fp.write("# HG changeset patch\n")
         fp.write("# User %s\n" % user)
         fp.write("# Date %d %d\n" % date)