comparison mercurial/dispatch.py @ 22276:b13b99d39a46

config: highlight parse error caused by leading spaces (issue3214) Added "unexpected leading whitespace" message to parse error when .hgrc has a line that starts with whitespace. Helps new users unfamiliar with syntax of rc file.
author Razvan Cojocaru <razvan.cojocaru93@gmail.com>
date Sun, 16 Mar 2014 17:31:31 +0200
parents efd65e51bc0b
children c828b61e0635
comparison
equal deleted inserted replaced
22275:d9a8017dce10 22276:b13b99d39a46
56 return -1 56 return -1
57 except error.ParseError, inst: 57 except error.ParseError, inst:
58 if len(inst.args) > 1: 58 if len(inst.args) > 1:
59 ferr.write(_("hg: parse error at %s: %s\n") % 59 ferr.write(_("hg: parse error at %s: %s\n") %
60 (inst.args[1], inst.args[0])) 60 (inst.args[1], inst.args[0]))
61 if (inst.args[0][0] == ' '):
62 ferr.write(_("unexpected leading whitespace\n"))
61 else: 63 else:
62 ferr.write(_("hg: parse error: %s\n") % inst.args[0]) 64 ferr.write(_("hg: parse error: %s\n") % inst.args[0])
63 return -1 65 return -1
64 66
65 msg = ' '.join(' ' in a and repr(a) or a for a in req.args) 67 msg = ' '.join(' ' in a and repr(a) or a for a in req.args)
153 (inst.args[0], " ".join(inst.args[1]))) 155 (inst.args[0], " ".join(inst.args[1])))
154 except error.ParseError, inst: 156 except error.ParseError, inst:
155 if len(inst.args) > 1: 157 if len(inst.args) > 1:
156 ui.warn(_("hg: parse error at %s: %s\n") % 158 ui.warn(_("hg: parse error at %s: %s\n") %
157 (inst.args[1], inst.args[0])) 159 (inst.args[1], inst.args[0]))
160 if (inst.args[0][0] == ' '):
161 ui.warn(_("unexpected leading whitespace\n"))
158 else: 162 else:
159 ui.warn(_("hg: parse error: %s\n") % inst.args[0]) 163 ui.warn(_("hg: parse error: %s\n") % inst.args[0])
160 return -1 164 return -1
161 except error.LockHeld, inst: 165 except error.LockHeld, inst:
162 if inst.errno == errno.ETIMEDOUT: 166 if inst.errno == errno.ETIMEDOUT: