comparison mercurial/utils/procutil.py @ 45094:b4c35e439ea5

procutil: move assignments This should probably be part of the previous patch, but folding it results in a less useful word diff, so I decided to keep it separate for review.
author Manuel Jacob <me@manueljacob.de>
date Sat, 11 Jul 2020 07:47:04 +0200
parents 63196198dbf0
children 8e04607023e5
comparison
equal deleted inserted replaced
45093:63196198dbf0 45094:b4c35e439ea5
84 # Python 3 implements its own I/O streams. 84 # Python 3 implements its own I/O streams.
85 # TODO: .buffer might not exist if std streams were replaced; we'll need 85 # TODO: .buffer might not exist if std streams were replaced; we'll need
86 # a silly wrapper to make a bytes stream backed by a unicode one. 86 # a silly wrapper to make a bytes stream backed by a unicode one.
87 stdin = sys.stdin.buffer 87 stdin = sys.stdin.buffer
88 stdout = sys.stdout.buffer 88 stdout = sys.stdout.buffer
89 stderr = sys.stderr.buffer
90 if isatty(stdout): 89 if isatty(stdout):
91 # The standard library doesn't offer line-buffered binary streams. 90 # The standard library doesn't offer line-buffered binary streams.
92 stdout = make_line_buffered(stdout) 91 stdout = make_line_buffered(stdout)
92 stderr = sys.stderr.buffer
93 else: 93 else:
94 # Python 2 uses the I/O streams provided by the C library. 94 # Python 2 uses the I/O streams provided by the C library.
95 stdin = sys.stdin 95 stdin = sys.stdin
96 stdout = sys.stdout 96 stdout = sys.stdout
97 stderr = sys.stderr
98 if isatty(stdout): 97 if isatty(stdout):
99 if pycompat.iswindows: 98 if pycompat.iswindows:
100 # Work around size limit when writing to console. 99 # Work around size limit when writing to console.
101 stdout = platform.winstdout(stdout) 100 stdout = platform.winstdout(stdout)
102 # The Windows C runtime library doesn't support line buffering. 101 # The Windows C runtime library doesn't support line buffering.
104 else: 103 else:
105 # glibc determines buffering on first write to stdout - if we 104 # glibc determines buffering on first write to stdout - if we
106 # replace a TTY destined stdout with a pipe destined stdout (e.g. 105 # replace a TTY destined stdout with a pipe destined stdout (e.g.
107 # pager), we want line buffering. 106 # pager), we want line buffering.
108 stdout = os.fdopen(stdout.fileno(), 'wb', 1) 107 stdout = os.fdopen(stdout.fileno(), 'wb', 1)
108 stderr = sys.stderr
109 109
110 110
111 findexe = platform.findexe 111 findexe = platform.findexe
112 _gethgcmd = platform.gethgcmd 112 _gethgcmd = platform.gethgcmd
113 getuser = platform.getuser 113 getuser = platform.getuser