mercurial/ui.py
changeset 32962 0bf986cfa82b
parent 32961 24111157f967
child 32963 88b3a38d39e3
equal deleted inserted replaced
32961:24111157f967 32962:0bf986cfa82b
   594         """
   594         """
   595 
   595 
   596         return self.configwith(int, section, name, default, 'integer',
   596         return self.configwith(int, section, name, default, 'integer',
   597                                untrusted)
   597                                untrusted)
   598 
   598 
   599     def configbytes(self, section, name, default=0, untrusted=False):
   599     def configbytes(self, section, name, default=_unset, untrusted=False):
   600         """parse a configuration element as a quantity in bytes
   600         """parse a configuration element as a quantity in bytes
   601 
   601 
   602         Units can be specified as b (bytes), k or kb (kilobytes), m or
   602         Units can be specified as b (bytes), k or kb (kilobytes), m or
   603         mb (megabytes), g or gb (gigabytes).
   603         mb (megabytes), g or gb (gigabytes).
   604 
   604 
   616         Traceback (most recent call last):
   616         Traceback (most recent call last):
   617             ...
   617             ...
   618         ConfigError: foo.invalid is not a byte quantity ('somevalue')
   618         ConfigError: foo.invalid is not a byte quantity ('somevalue')
   619         """
   619         """
   620 
   620 
   621         value = self.config(section, name, None, untrusted)
   621         value = self.config(section, name, default, untrusted)
   622         if value is None:
   622         if value is None:
   623             if not isinstance(default, str):
   623             if default is _unset:
   624                 return default
   624                 default = 0
   625             value = default
   625             value = default
       
   626         if not isinstance(value, str):
       
   627             return value
   626         try:
   628         try:
   627             return util.sizetoint(value)
   629             return util.sizetoint(value)
   628         except error.ParseError:
   630         except error.ParseError:
   629             raise error.ConfigError(_("%s.%s is not a byte quantity ('%s')")
   631             raise error.ConfigError(_("%s.%s is not a byte quantity ('%s')")
   630                                     % (section, name, value))
   632                                     % (section, name, value))