mercurial/utils/procutil.py
changeset 45043 be58fb1eaa73
parent 45042 c88577199023
child 45045 8403cc54bc83
equal deleted inserted replaced
45042:c88577199023 45043:be58fb1eaa73
    82 
    82 
    83 stderr = pycompat.stderr
    83 stderr = pycompat.stderr
    84 stdin = pycompat.stdin
    84 stdin = pycompat.stdin
    85 stdout = pycompat.stdout
    85 stdout = pycompat.stdout
    86 
    86 
       
    87 if pycompat.iswindows:
       
    88     stdout = platform.winstdout(stdout)
       
    89 
    87 # glibc determines buffering on first write to stdout - if we replace a TTY
    90 # glibc determines buffering on first write to stdout - if we replace a TTY
    88 # destined stdout with a pipe destined stdout (e.g. pager), we want line
    91 # destined stdout with a pipe destined stdout (e.g. pager), we want line
    89 # buffering (or unbuffered, on Windows)
    92 # buffering.
    90 if isatty(stdout):
    93 if isatty(stdout):
    91     if pycompat.iswindows:
    94     if pycompat.ispy3 or pycompat.iswindows:
    92         # Windows doesn't support line buffering
       
    93         stdout = os.fdopen(stdout.fileno(), 'wb', 0)
       
    94     elif pycompat.ispy3:
       
    95         # On Python 3, buffered binary streams can't be set line-buffered.
    95         # On Python 3, buffered binary streams can't be set line-buffered.
       
    96         # On Python 2, Windows doesn't support line buffering.
    96         # Therefore we have a wrapper that implements line buffering.
    97         # Therefore we have a wrapper that implements line buffering.
    97         stdout = make_line_buffered(stdout)
    98         stdout = make_line_buffered(stdout)
    98     else:
    99     else:
    99         stdout = os.fdopen(stdout.fileno(), 'wb', 1)
   100         stdout = os.fdopen(stdout.fileno(), 'wb', 1)
   100 
       
   101 if pycompat.iswindows:
       
   102     stdout = platform.winstdout(stdout)
       
   103 
   101 
   104 
   102 
   105 findexe = platform.findexe
   103 findexe = platform.findexe
   106 _gethgcmd = platform.gethgcmd
   104 _gethgcmd = platform.gethgcmd
   107 getuser = platform.getuser
   105 getuser = platform.getuser