# HG changeset patch # User Yuya Nishihara # Date 2018-03-10 10:49:09 # Node ID c268ba15deb351525b63d9c3438c0013ffc24d6c # Parent 472c68cda3f8240c51c9808df55b9a3435b353f5 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. diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1120,9 +1120,10 @@ the hunk is left unchanged. 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()