Mercurial > hg
comparison mercurial/debugcommands.py @ 38313:275cc461b854
debugcommands: work around logiofd being a pipe and unseekable
This was breaking in our Python 3 build, but not Python 2. I don't
know how it ever worked in Python 2, but this passes on both.
Differential Revision: https://phab.mercurial-scm.org/D3732
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 14 Jun 2018 11:47:51 -0400 |
parents | dbf31732ef64 |
children | d4fae9a0ab1f |
comparison
equal
deleted
inserted
replaced
38312:79dd61a4554f | 38313:275cc461b854 |
---|---|
2287 if opts['logiofd'] and opts['logiofile']: | 2287 if opts['logiofd'] and opts['logiofile']: |
2288 raise error.Abort(_('cannot use both --logiofd and --logiofile')) | 2288 raise error.Abort(_('cannot use both --logiofd and --logiofile')) |
2289 | 2289 |
2290 if opts['logiofd']: | 2290 if opts['logiofd']: |
2291 # Line buffered because output is line based. | 2291 # Line buffered because output is line based. |
2292 logfh = os.fdopen(int(opts['logiofd']), r'ab', 1) | 2292 try: |
2293 logfh = os.fdopen(int(opts['logiofd']), r'ab', 1) | |
2294 except OSError as e: | |
2295 if e.errno != errno.ESPIPE: | |
2296 raise | |
2297 # can't seek a pipe, so `ab` mode fails on py3 | |
2298 logfh = os.fdopen(int(opts['logiofd']), r'wb', 1) | |
2293 elif opts['logiofile']: | 2299 elif opts['logiofile']: |
2294 logfh = open(opts['logiofile'], 'ab', 1) | 2300 logfh = open(opts['logiofile'], 'ab', 1) |
2295 | 2301 |
2296 s = wireprotoserver.sshserver(ui, repo, logfh=logfh) | 2302 s = wireprotoserver.sshserver(ui, repo, logfh=logfh) |
2297 s.serve_forever() | 2303 s.serve_forever() |