Patchwork [4,of,6] procutil: move assignments closer to reassignments

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

Comments

Manuel Jacob - July 5, 2020, 2:51 a.m.
# HG changeset patch
# User Manuel Jacob <me@manueljacob.de>
# Date 1593854158 -7200
#      Sat Jul 04 11:15:58 2020 +0200
# Node ID b0a51f31a3aedba6c0d3b0b79490a67f070c077c
# Parent  e5036c93535df61100895be58ae8aabad5592328
# EXP-Topic stdio
procutil: move assignments closer to reassignments

Doing reassignments is an anti-pattern IMHO, but I see how it makes sense here.
When first looking at this code after jumping here with ctags, I missed the
fact that stdout was reassigned. To make the code clearer, the assignments
should be as close as possible to the reassignments.

Patch

diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -37,10 +37,6 @@ 
 
 osutil = policy.importmod('osutil')
 
-stderr = pycompat.stderr
-stdin = pycompat.stdin
-stdout = pycompat.stdout
-
 
 def isatty(fp):
     try:
@@ -79,6 +75,10 @@ 
     return LineBufferedWrapper(stream)
 
 
+stderr = pycompat.stderr
+stdin = pycompat.stdin
+stdout = pycompat.stdout
+
 # glibc determines buffering on first write to stdout - if we replace a TTY
 # destined stdout with a pipe destined stdout (e.g. pager), we want line
 # buffering (or unbuffered, on Windows)