Patchwork [2,of,2] py3: don't use universal_newlines in svnsubrepo

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 2, 2019, 6:38 a.m.
Message ID <dbf20e28d1a67b05e4c9.1549089533@mimosa>
Download mbox | patch
Permalink /patch/38325/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 2, 2019, 6:38 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1549088811 -32400
#      Sat Feb 02 15:26:51 2019 +0900
# Node ID dbf20e28d1a67b05e4c9f93c69be2f808647a9fd
# Parent  921b4ffa9ced910ea79cb839b86a06287710f29c
py3: don't use universal_newlines in svnsubrepo

On Python 3, it means text=True without any specific encoding, which is
pretty bad. Instead, use util.fromnativeeol() to translate CR+LF to LF
without encoding conversion.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -958,10 +958,8 @@  class svnsubrepo(abstractsubrepo):
         p = subprocess.Popen(pycompat.rapply(procutil.tonativestr, cmd),
                              bufsize=-1, close_fds=procutil.closefds,
                              stdout=subprocess.PIPE, stderr=subprocess.PIPE,
-                             universal_newlines=True,
                              env=procutil.tonativeenv(env), **extrakw)
-        stdout, stderr = p.communicate()
-        stdout, stderr = pycompat.fsencode(stdout), pycompat.fsencode(stderr)
+        stdout, stderr = map(util.fromnativeeol, p.communicate())
         stderr = stderr.strip()
         if not failok:
             if p.returncode: