##// END OF EJS Templates
debugserve: migrate `opts` to native kwargs
Matt Harbison -
r51860:36f11682 default
parent child Browse files
Show More
@@ -3490,30 +3490,28 b' def debugserve(ui, repo, **opts):'
3490 workaround to the fact that ``hg serve --stdio`` must have specific
3490 workaround to the fact that ``hg serve --stdio`` must have specific
3491 arguments for security reasons.
3491 arguments for security reasons.
3492 """
3492 """
3493 opts = pycompat.byteskwargs(opts)
3493 if not opts['sshstdio']:
3494
3495 if not opts[b'sshstdio']:
3496 raise error.Abort(_(b'only --sshstdio is currently supported'))
3494 raise error.Abort(_(b'only --sshstdio is currently supported'))
3497
3495
3498 logfh = None
3496 logfh = None
3499
3497
3500 if opts[b'logiofd'] and opts[b'logiofile']:
3498 if opts['logiofd'] and opts['logiofile']:
3501 raise error.Abort(_(b'cannot use both --logiofd and --logiofile'))
3499 raise error.Abort(_(b'cannot use both --logiofd and --logiofile'))
3502
3500
3503 if opts[b'logiofd']:
3501 if opts['logiofd']:
3504 # Ideally we would be line buffered. But line buffering in binary
3502 # Ideally we would be line buffered. But line buffering in binary
3505 # mode isn't supported and emits a warning in Python 3.8+. Disabling
3503 # mode isn't supported and emits a warning in Python 3.8+. Disabling
3506 # buffering could have performance impacts. But since this isn't
3504 # buffering could have performance impacts. But since this isn't
3507 # performance critical code, it should be fine.
3505 # performance critical code, it should be fine.
3508 try:
3506 try:
3509 logfh = os.fdopen(int(opts[b'logiofd']), 'ab', 0)
3507 logfh = os.fdopen(int(opts['logiofd']), 'ab', 0)
3510 except OSError as e:
3508 except OSError as e:
3511 if e.errno != errno.ESPIPE:
3509 if e.errno != errno.ESPIPE:
3512 raise
3510 raise
3513 # can't seek a pipe, so `ab` mode fails on py3
3511 # can't seek a pipe, so `ab` mode fails on py3
3514 logfh = os.fdopen(int(opts[b'logiofd']), 'wb', 0)
3512 logfh = os.fdopen(int(opts['logiofd']), 'wb', 0)
3515 elif opts[b'logiofile']:
3513 elif opts['logiofile']:
3516 logfh = open(opts[b'logiofile'], b'ab', 0)
3514 logfh = open(opts['logiofile'], b'ab', 0)
3517
3515
3518 s = wireprotoserver.sshserver(ui, repo, logfh=logfh)
3516 s = wireprotoserver.sshserver(ui, repo, logfh=logfh)
3519 s.serve_forever()
3517 s.serve_forever()
General Comments 0
You need to be logged in to leave comments. Login now