Skip to content
Snippets Groups Projects
Commit 9311cd5c authored by Bryan O'Sullivan's avatar Bryan O'Sullivan
Browse files

ui: use util.sizetoint in configbytes

parent 1d08df65
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@
# GNU General Public License version 2 or any later version.
from i18n import _
import errno, getpass, os, re, socket, sys, tempfile, traceback
import errno, getpass, os, socket, sys, tempfile, traceback
import config, scmutil, util, error, formatter
class ui(object):
......@@ -284,7 +284,7 @@
ConfigError: foo.invalid is not a byte quantity ('somevalue')
"""
orig = string = self.config(section, name)
if orig is None:
value = self.config(section, name)
if value is None:
if not isinstance(default, str):
return default
......@@ -289,10 +289,4 @@
if not isinstance(default, str):
return default
orig = string = default
multiple = 1
m = re.match(r'([^kmbg]+?)\s*([kmg]?)b?$', string, re.I)
if m:
string, key = m.groups()
key = key.lower()
multiple = dict(k=1024, m=1048576, g=1073741824).get(key, 1)
value = default
try:
......@@ -298,4 +292,4 @@
try:
return int(float(string) * multiple)
except ValueError:
return util.sizetoint(value)
except error.ParseError:
raise error.ConfigError(_("%s.%s is not a byte quantity ('%s')")
......@@ -301,5 +295,5 @@
raise error.ConfigError(_("%s.%s is not a byte quantity ('%s')")
% (section, name, orig))
% (section, name, value))
def configlist(self, section, name, default=None, untrusted=False):
"""parse a configuration element as a list of comma/space separated
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment