Patchwork [1,of,2,V2] dispatch: extra common logic for handling ParseError

login
register
mail settings
Submitter Jun Wu
Date March 14, 2016, 1:01 p.m.
Message ID <e57b54cc488387c44eb8.1457960488@x1c>
Download mbox | patch
Permalink /patch/13863/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Jun Wu - March 14, 2016, 1:01 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1457958729 0
#      Mon Mar 14 12:32:09 2016 +0000
# Node ID e57b54cc488387c44eb85e0ef30f5c87619c20c3
# Parent  40b571e817902d930d1d828769d2d29bbba88de1
dispatch: extra 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.
Jun Wu - March 14, 2016, 1:10 p.m.
On 03/14/2016 01:01 PM, Jun Wu wrote:
> dispatch: extra common logic for handling ParseError

Sorry. "extra" should be "extract".

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -81,6 +81,8 @@ 
     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 @@ 
         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 @@ 
                 (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: