mercurial/utils/procutil.py
changeset 45148 a37f290a7124
parent 45103 a5fa2761a6cd
child 45786 37c65704869d
child 46019 fdd54a876213
equal deleted inserted replaced
45147:c2c862b9b544 45148:a37f290a7124
   117     # Python 3 implements its own I/O streams.
   117     # Python 3 implements its own I/O streams.
   118     # TODO: .buffer might not exist if std streams were replaced; we'll need
   118     # TODO: .buffer might not exist if std streams were replaced; we'll need
   119     # a silly wrapper to make a bytes stream backed by a unicode one.
   119     # a silly wrapper to make a bytes stream backed by a unicode one.
   120     stdin = sys.stdin.buffer
   120     stdin = sys.stdin.buffer
   121     stdout = _make_write_all(sys.stdout.buffer)
   121     stdout = _make_write_all(sys.stdout.buffer)
       
   122     stderr = _make_write_all(sys.stderr.buffer)
       
   123     if pycompat.iswindows:
       
   124         # Work around Windows bugs.
       
   125         stdout = platform.winstdout(stdout)
       
   126         stderr = platform.winstdout(stderr)
   122     if isatty(stdout):
   127     if isatty(stdout):
   123         # The standard library doesn't offer line-buffered binary streams.
   128         # The standard library doesn't offer line-buffered binary streams.
   124         stdout = make_line_buffered(stdout)
   129         stdout = make_line_buffered(stdout)
   125     stderr = _make_write_all(sys.stderr.buffer)
       
   126 else:
   130 else:
   127     # Python 2 uses the I/O streams provided by the C library.
   131     # Python 2 uses the I/O streams provided by the C library.
   128     stdin = sys.stdin
   132     stdin = sys.stdin
   129     stdout = sys.stdout
   133     stdout = sys.stdout
       
   134     stderr = sys.stderr
       
   135     if pycompat.iswindows:
       
   136         # Work around Windows bugs.
       
   137         stdout = platform.winstdout(stdout)
       
   138         stderr = platform.winstdout(stderr)
   130     if isatty(stdout):
   139     if isatty(stdout):
   131         if pycompat.iswindows:
   140         if pycompat.iswindows:
   132             # Work around size limit when writing to console.
       
   133             stdout = platform.winstdout(stdout)
       
   134             # The Windows C runtime library doesn't support line buffering.
   141             # The Windows C runtime library doesn't support line buffering.
   135             stdout = make_line_buffered(stdout)
   142             stdout = make_line_buffered(stdout)
   136         else:
   143         else:
   137             # glibc determines buffering on first write to stdout - if we
   144             # glibc determines buffering on first write to stdout - if we
   138             # replace a TTY destined stdout with a pipe destined stdout (e.g.
   145             # replace a TTY destined stdout with a pipe destined stdout (e.g.
   139             # pager), we want line buffering.
   146             # pager), we want line buffering.
   140             stdout = os.fdopen(stdout.fileno(), 'wb', 1)
   147             stdout = os.fdopen(stdout.fileno(), 'wb', 1)
   141     stderr = sys.stderr
       
   142 
   148 
   143 
   149 
   144 findexe = platform.findexe
   150 findexe = platform.findexe
   145 _gethgcmd = platform.gethgcmd
   151 _gethgcmd = platform.gethgcmd
   146 getuser = platform.getuser
   152 getuser = platform.getuser