changeset 36838:c268ba15deb3

py3: open patch file in binary mode and convert eol manually Here we don't introduce a reader wrapper since it wouldn't be easy to make read(n) handle partial data and length correctly.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 10 Mar 2018 19:49:09 +0900
parents 472c68cda3f8
children 5b9ae9eca94a
files mercurial/patch.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Tue Mar 06 07:45:57 2018 -0600
+++ b/mercurial/patch.py	Sat Mar 10 19:49:09 2018 +0900
@@ -1120,9 +1120,10 @@
                         ui.warn(_("editor exited with exit code %d\n") % ret)
                         continue
                     # Remove comment lines
-                    patchfp = open(patchfn)
+                    patchfp = open(patchfn, r'rb')
                     ncpatchfp = stringio()
                     for line in util.iterfile(patchfp):
+                        line = util.fromnativeeol(line)
                         if not line.startswith('#'):
                             ncpatchfp.write(line)
                     patchfp.close()