# HG changeset patch # User Thomas Arendsen Hein # Date 1182883035 -7200 # Node ID 9881abfc0e442440dd39ca27e1442869366f96e0 # Parent 7bb5bcb089e3fc06aaa365d0e40689ce268b3db4 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. diff -r 7bb5bcb089e3 -r 9881abfc0e44 mercurial/ui.py --- 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: diff -r 7bb5bcb089e3 -r 9881abfc0e44 tests/test-ui-config --- 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)) diff -r 7bb5bcb089e3 -r 9881abfc0e44 tests/test-ui-config.out --- 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