##// END OF EJS Templates
dispatch: consolidate formatting of ParseErrors
Augie Fackler -
r24039:2ee35b6e default
parent child Browse files
Show More
@@ -27,6 +27,15 b' def run():'
27 "run the command in sys.argv"
27 "run the command in sys.argv"
28 sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
28 sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
29
29
30 def _formatparse(write, inst):
31 if len(inst.args) > 1:
32 write(_("hg: parse error at %s: %s\n") %
33 (inst.args[1], inst.args[0]))
34 if (inst.args[0][0] == ' '):
35 write(_("unexpected leading whitespace\n"))
36 else:
37 write(_("hg: parse error: %s\n") % inst.args[0])
38
30 def dispatch(req):
39 def dispatch(req):
31 "run the command specified in req.args"
40 "run the command specified in req.args"
32 if req.ferr:
41 if req.ferr:
@@ -55,13 +64,7 b' def dispatch(req):'
55 ferr.write(_("(%s)\n") % inst.hint)
64 ferr.write(_("(%s)\n") % inst.hint)
56 return -1
65 return -1
57 except error.ParseError, inst:
66 except error.ParseError, inst:
58 if len(inst.args) > 1:
67 _formatparse(ferr.write, inst)
59 ferr.write(_("hg: parse error at %s: %s\n") %
60 (inst.args[1], inst.args[0]))
61 if (inst.args[0][0] == ' '):
62 ferr.write(_("unexpected leading whitespace\n"))
63 else:
64 ferr.write(_("hg: parse error: %s\n") % inst.args[0])
65 return -1
68 return -1
66
69
67 msg = ' '.join(' ' in a and repr(a) or a for a in req.args)
70 msg = ' '.join(' ' in a and repr(a) or a for a in req.args)
@@ -154,13 +157,7 b' def _runcatch(req):'
154 ui.warn(_("hg: command '%s' is ambiguous:\n %s\n") %
157 ui.warn(_("hg: command '%s' is ambiguous:\n %s\n") %
155 (inst.args[0], " ".join(inst.args[1])))
158 (inst.args[0], " ".join(inst.args[1])))
156 except error.ParseError, inst:
159 except error.ParseError, inst:
157 if len(inst.args) > 1:
160 _formatparse(ui.warn, inst)
158 ui.warn(_("hg: parse error at %s: %s\n") %
159 (inst.args[1], inst.args[0]))
160 if (inst.args[0][0] == ' '):
161 ui.warn(_("unexpected leading whitespace\n"))
162 else:
163 ui.warn(_("hg: parse error: %s\n") % inst.args[0])
164 return -1
161 return -1
165 except error.LockHeld, inst:
162 except error.LockHeld, inst:
166 if inst.errno == errno.ETIMEDOUT:
163 if inst.errno == errno.ETIMEDOUT:
General Comments 0
You need to be logged in to leave comments. Login now