From patchwork Mon Jul 6 12:03:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,6,v2] procutil: split import and reassignment From: Manuel Jacob X-Patchwork-Id: 46632 Message-Id: <56b835bd7cb4c1667030.1594036995@tmp> To: mercurial-devel@mercurial-scm.org Date: Mon, 06 Jul 2020 14:03:15 +0200 # HG changeset patch # User Manuel Jacob # Date 1593854504 -7200 # Sat Jul 04 11:21:44 2020 +0200 # Node ID 56b835bd7cb4c166703046300562ce3bd3e4088c # Parent 271329a28ae25a0301128c90c526c67b05346f9f # EXP-Topic stdio procutil: split import and reassignment Besides making the code clearer, it will reduce the diff in the next patch. diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py --- a/mercurial/utils/procutil.py +++ b/mercurial/utils/procutil.py @@ -37,6 +37,11 @@ osutil = policy.importmod('osutil') +if pycompat.iswindows: + from .. import windows as platform +else: + from .. import posix as platform + def isatty(fp): try: @@ -94,11 +99,8 @@ stdout = os.fdopen(stdout.fileno(), 'wb', 1) if pycompat.iswindows: - from .. import windows as platform + stdout = platform.winstdout(stdout) - stdout = platform.winstdout(stdout) -else: - from .. import posix as platform findexe = platform.findexe _gethgcmd = platform.gethgcmd