##// END OF EJS Templates
ui: rewrite configint in terms of configwith
Bryan O'Sullivan -
r30927:8fa3ab62 default
parent child Browse files
Show More
@@ -453,17 +453,11 b' class ui(object):'
453 >>> u.configint(s, 'invalid')
453 >>> u.configint(s, 'invalid')
454 Traceback (most recent call last):
454 Traceback (most recent call last):
455 ...
455 ...
456 ConfigError: foo.invalid is not an integer ('somevalue')
456 ConfigError: foo.invalid is not a valid integer ('somevalue')
457 """
457 """
458
458
459 v = self.config(section, name, None, untrusted)
459 return self.configwith(int, section, name, default, 'integer',
460 if v is None:
460 untrusted)
461 return default
462 try:
463 return int(v)
464 except ValueError:
465 raise error.ConfigError(_("%s.%s is not an integer ('%s')")
466 % (section, name, v))
467
461
468 def configbytes(self, section, name, default=0, untrusted=False):
462 def configbytes(self, section, name, default=0, untrusted=False):
469 """parse a configuration element as a quantity in bytes
463 """parse a configuration element as a quantity in bytes
@@ -330,7 +330,7 b' since bar is not touched in this commit,'
330
330
331 input validation
331 input validation
332 $ hg convert --config convert.git.similarity=foo --datesort git-repo2 fullrepo
332 $ hg convert --config convert.git.similarity=foo --datesort git-repo2 fullrepo
333 abort: convert.git.similarity is not an integer ('foo')
333 abort: convert.git.similarity is not a valid integer ('foo')
334 [255]
334 [255]
335 $ hg convert --config convert.git.similarity=-1 --datesort git-repo2 fullrepo
335 $ hg convert --config convert.git.similarity=-1 --datesort git-repo2 fullrepo
336 abort: similarity must be between 0 and 100
336 abort: similarity must be between 0 and 100
General Comments 0
You need to be logged in to leave comments. Login now