# HG changeset patch # User Pierre-Yves David # Date 1497696751 -7200 # Node ID 6ff6eb33f3537af9ce1fcf0444dc1329986db5db # Parent b39dafe681df731c4760b46b0cf575c6f1ebb14f config: use the new '_unset' value for 'configwith' This should let 'configwith' delegate all special processing of the default config value to the main 'config' method. This changeset introduce a small change in behavior since the default value is run through the 'convert' function. This does not seems harmful and no actual test break. This small change make the code simpler so I'm keeping it. diff -r b39dafe681df -r 6ff6eb33f353 mercurial/ui.py --- a/mercurial/ui.py Sat Jun 17 12:52:16 2017 +0200 +++ b/mercurial/ui.py Sat Jun 17 12:52:31 2017 +0200 @@ -539,7 +539,7 @@ % (section, name, v)) return b - def configwith(self, convert, section, name, default=None, + def configwith(self, convert, section, name, default=_unset, desc=None, untrusted=False): """parse a configuration element with a conversion function @@ -551,7 +551,7 @@ >>> u.configwith(float, s, 'float2') -4.25 >>> u.configwith(float, s, 'unknown', 7) - 7 + 7.0 >>> u.setconfig(s, 'invalid', 'somevalue') >>> u.configwith(float, s, 'invalid') Traceback (most recent call last): @@ -563,9 +563,9 @@ ConfigError: foo.invalid is not a valid womble ('somevalue') """ - v = self.config(section, name, None, untrusted) + v = self.config(section, name, default, untrusted) if v is None: - return default + return v # do not attempt to convert None try: return convert(v) except (ValueError, error.ParseError):