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	Tue Jun 26 18:39:28 2007 +0200
+++ b/mercurial/ui.py	Tue Jun 26 20:37:15 2007 +0200
@@ -237,7 +237,7 @@
             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	Tue Jun 26 18:39:28 2007 +0200
+++ b/tests/test-ui-config	Tue Jun 26 20:37:15 2007 +0200
@@ -34,8 +34,8 @@
 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	Tue Jun 26 18:39:28 2007 +0200
+++ b/tests/test-ui-config.out	Tue Jun 26 20:37:15 2007 +0200
@@ -8,6 +8,7 @@
 'false'
 None
 ---
+Error in configuration section [values] parameter 'string':
 Not a boolean: string value
 True
 False