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

login
register
mail settings
Submitter Manuel Jacob
Date July 5, 2020, 2:51 a.m.
Message ID <7fb9114235241b6d4354.1593917501@tmp.fritz.box>
Download mbox | patch
Permalink /patch/46623/
State Accepted
Headers show

Comments

Manuel Jacob - July 5, 2020, 2:51 a.m.
# HG changeset patch
# User Manuel Jacob <me@manueljacob.de>
# Date 1593854504 -7200
#      Sat Jul 04 11:21:44 2020 +0200
# Node ID 7fb9114235241b6d4354b22e2ba08138bde58642
# Parent  b0a51f31a3aedba6c0d3b0b79490a67f070c077c
# 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