ui: rewrite configint in terms of configwith
authorBryan O'Sullivan <bryano@fb.com>
Sun, 12 Feb 2017 21:44:55 -0800
changeset 30927 8fa3ab6221b9
parent 30926 120682fce099
child 30928 be3a4fde38eb
ui: rewrite configint in terms of configwith
mercurial/ui.py
tests/test-convert-git.t
--- a/mercurial/ui.py	Sun Feb 12 21:40:46 2017 -0800
+++ b/mercurial/ui.py	Sun Feb 12 21:44:55 2017 -0800
@@ -453,17 +453,11 @@
         >>> u.configint(s, 'invalid')
         Traceback (most recent call last):
             ...
-        ConfigError: foo.invalid is not an integer ('somevalue')
+        ConfigError: foo.invalid is not a valid integer ('somevalue')
         """
 
-        v = self.config(section, name, None, untrusted)
-        if v is None:
-            return default
-        try:
-            return int(v)
-        except ValueError:
-            raise error.ConfigError(_("%s.%s is not an integer ('%s')")
-                                    % (section, name, v))
+        return self.configwith(int, section, name, default, 'integer',
+                               untrusted)
 
     def configbytes(self, section, name, default=0, untrusted=False):
         """parse a configuration element as a quantity in bytes
--- a/tests/test-convert-git.t	Sun Feb 12 21:40:46 2017 -0800
+++ b/tests/test-convert-git.t	Sun Feb 12 21:44:55 2017 -0800
@@ -330,7 +330,7 @@
 
 input validation
   $ hg convert --config convert.git.similarity=foo --datesort git-repo2 fullrepo
-  abort: convert.git.similarity is not an integer ('foo')
+  abort: convert.git.similarity is not a valid integer ('foo')
   [255]
   $ hg convert --config convert.git.similarity=-1 --datesort git-repo2 fullrepo
   abort: similarity must be between 0 and 100