Mercurial > public > mercurial-scm > hg
comparison mercurial/utils/procutil.py @ 45041:1053f878dd46
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.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Sat, 04 Jul 2020 11:15:58 +0200 |
parents | fd205a9c358a |
children | c88577199023 |
comparison
equal
deleted
inserted
replaced
45040:fd205a9c358a | 45041:1053f878dd46 |
---|---|
34 | 34 |
35 # Import like this to keep import-checker happy | 35 # Import like this to keep import-checker happy |
36 from ..utils import resourceutil | 36 from ..utils import resourceutil |
37 | 37 |
38 osutil = policy.importmod('osutil') | 38 osutil = policy.importmod('osutil') |
39 | |
40 stderr = pycompat.stderr | |
41 stdin = pycompat.stdin | |
42 stdout = pycompat.stdout | |
43 | 39 |
44 | 40 |
45 def isatty(fp): | 41 def isatty(fp): |
46 try: | 42 try: |
47 return fp.isatty() | 43 return fp.isatty() |
76 return stream | 72 return stream |
77 if isinstance(stream, LineBufferedWrapper): | 73 if isinstance(stream, LineBufferedWrapper): |
78 return stream | 74 return stream |
79 return LineBufferedWrapper(stream) | 75 return LineBufferedWrapper(stream) |
80 | 76 |
77 | |
78 stderr = pycompat.stderr | |
79 stdin = pycompat.stdin | |
80 stdout = pycompat.stdout | |
81 | 81 |
82 # glibc determines buffering on first write to stdout - if we replace a TTY | 82 # glibc determines buffering on first write to stdout - if we replace a TTY |
83 # destined stdout with a pipe destined stdout (e.g. pager), we want line | 83 # destined stdout with a pipe destined stdout (e.g. pager), we want line |
84 # buffering (or unbuffered, on Windows) | 84 # buffering (or unbuffered, on Windows) |
85 if isatty(stdout): | 85 if isatty(stdout): |