# HG changeset patch # User Jun Wu # Date 2016-03-14 12:32:09 # Node ID 491eabd0df79ac5f9a0719cd1c26e480212457ba # Parent 0747ef2c4ab25e6f0928143217588ad4f6698d9c dispatch: extract common logic for handling ParseError The way ParseError is handled at two different places in dispatch.py is the same. Move common logic into _formatparse. diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -81,6 +81,8 @@ def _formatparse(write, inst): else: write(_("hg: parse error: %s\n") % inst.args[0]) _reportsimilar(write, similar) + if inst.hint: + write(_("(%s)\n") % inst.hint) def dispatch(req): "run the command specified in req.args" @@ -111,8 +113,6 @@ def dispatch(req): return -1 except error.ParseError as inst: _formatparse(ferr.write, inst) - if inst.hint: - ferr.write(_("(%s)\n") % inst.hint) return -1 msg = ' '.join(' ' in a and repr(a) or a for a in req.args) @@ -208,8 +208,6 @@ def _runcatch(req): (inst.args[0], " ".join(inst.args[1]))) except error.ParseError as inst: _formatparse(ui.warn, inst) - if inst.hint: - ui.warn(_("(%s)\n") % inst.hint) return -1 except error.LockHeld as inst: if inst.errno == errno.ETIMEDOUT: