comparison mercurial/dispatch.py @ 45884:98399dd1b96c

errors: make formatparse() an instance method on ParseError It's just a little simpler this way. Don't ask me what the "hg: " prefix signifies to the user, I just left it as it was. I think we should consider changing the prefixes later (maybe always use "abort: ", or maybe use more specific prefixes in general). Differential Revision: https://phab.mercurial-scm.org/D9347
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 20 Nov 2020 08:51:45 -0800
parents 8cc9e7f762d6
children 600aec73f309
comparison
equal deleted inserted replaced
45883:1817b66897ad 45884:98399dd1b96c
259 ferr.write(_(b"abort: %s\n") % inst.message) 259 ferr.write(_(b"abort: %s\n") % inst.message)
260 if inst.hint: 260 if inst.hint:
261 ferr.write(_(b"(%s)\n") % inst.hint) 261 ferr.write(_(b"(%s)\n") % inst.hint)
262 return -1 262 return -1
263 except error.ParseError as inst: 263 except error.ParseError as inst:
264 scmutil.formatparse(ferr.write, inst) 264 ferr.write(inst.format())
265 return -1 265 return -1
266 266
267 msg = _formatargs(req.args) 267 msg = _formatargs(req.args)
268 starttime = util.timer() 268 starttime = util.timer()
269 ret = 1 # default of Python exit code on unhandled exception 269 ret = 1 # default of Python exit code on unhandled exception
467 commands.help_(ui, inst.command, full=False, command=True) 467 commands.help_(ui, inst.command, full=False, command=True)
468 else: 468 else:
469 ui.warn(_(b"hg: %s\n") % inst.message) 469 ui.warn(_(b"hg: %s\n") % inst.message)
470 ui.warn(_(b"(use 'hg help -v' for a list of global options)\n")) 470 ui.warn(_(b"(use 'hg help -v' for a list of global options)\n"))
471 except error.ParseError as inst: 471 except error.ParseError as inst:
472 scmutil.formatparse(ui.warn, inst) 472 ui.warn(inst.format())
473 return -1 473 return -1
474 except error.UnknownCommand as inst: 474 except error.UnknownCommand as inst:
475 nocmdmsg = _(b"hg: unknown command '%s'\n") % inst.command 475 nocmdmsg = _(b"hg: unknown command '%s'\n") % inst.command
476 try: 476 try:
477 # check if the command is in a disabled extension 477 # check if the command is in a disabled extension