Patchwork [3,of,6,v2] procutil: split import and reassignment

login
register
mail settings
Submitter Manuel Jacob
Date July 6, 2020, 12:03 p.m.
Message ID <56b835bd7cb4c1667030.1594036995@tmp>
Download mbox | patch
Permalink /patch/46632/
State Accepted
Headers show

Comments

Manuel Jacob - July 6, 2020, 12:03 p.m.
# HG changeset patch
# User Manuel Jacob <me@manueljacob.de>
# 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.

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