Catch illegal boolean values in hgrc nicely.
authorThomas Arendsen Hein <thomas@intevation.de>
Tue, 26 Jun 2007 20:37:15 +0200
changeset 4729 9881abfc0e44
parent 4728 7bb5bcb089e3
child 4730 eadfaa9ec487
Catch illegal boolean values in hgrc nicely. With hg 0.9.3 the section and parameter name wasn't printed, with hg 0.9.4 there was a traceback for ValueError.
mercurial/ui.py
tests/test-ui-config
tests/test-ui-config.out
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -237,7 +237,7 @@ class ui(object):
             try:
                 func = getattr(cdata, funcname)
                 return func(section, name)
-            except ConfigParser.InterpolationError, inst:
+            except (ConfigParser.InterpolationError, ValueError), inst:
                 msg = _("Error in configuration section [%s] "
                         "parameter '%s':\n%s") % (section, name, inst)
                 if abort:
--- a/tests/test-ui-config
+++ b/tests/test-ui-config
@@ -34,8 +34,8 @@ print repr(testui.config('values', 'unkn
 print "---"
 try:
     print repr(testui.configbool('values', 'string'))
-except ValueError, why:
-    print why
+except util.Abort, inst:
+    print inst
 print repr(testui.configbool('values', 'bool1'))
 print repr(testui.configbool('values', 'bool2'))
 print repr(testui.configbool('values', 'bool2', True))
--- a/tests/test-ui-config.out
+++ b/tests/test-ui-config.out
@@ -8,6 +8,7 @@ Error in configuration section [interpol
 'false'
 None
 ---
+Error in configuration section [values] parameter 'string':
 Not a boolean: string value
 True
 False