changeset 32962:0bf986cfa82b

config: use the new '_unset' value for 'configbytes' This should let 'configbytes' delegates all special processing of the default config value to the main 'config' method.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 17 Jun 2017 12:53:51 +0200
parents 24111157f967
children 88b3a38d39e3
files mercurial/ui.py
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Sat Jun 17 12:53:40 2017 +0200
+++ b/mercurial/ui.py	Sat Jun 17 12:53:51 2017 +0200
@@ -596,7 +596,7 @@
         return self.configwith(int, section, name, default, 'integer',
                                untrusted)
 
-    def configbytes(self, section, name, default=0, untrusted=False):
+    def configbytes(self, section, name, default=_unset, untrusted=False):
         """parse a configuration element as a quantity in bytes
 
         Units can be specified as b (bytes), k or kb (kilobytes), m or
@@ -618,11 +618,13 @@
         ConfigError: foo.invalid is not a byte quantity ('somevalue')
         """
 
-        value = self.config(section, name, None, untrusted)
+        value = self.config(section, name, default, untrusted)
         if value is None:
-            if not isinstance(default, str):
-                return default
+            if default is _unset:
+                default = 0
             value = default
+        if not isinstance(value, str):
+            return value
         try:
             return util.sizetoint(value)
         except error.ParseError: