[PATCH 2 of 4] ui: rewrite configint in terms of configwith
Bryan O'Sullivan
bos at serpentine.com
Mon Feb 13 06:37:42 UTC 2017
# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1486964695 28800
# Sun Feb 12 21:44:55 2017 -0800
# Node ID 270342e743efcba76028840c357bb930cd1166f4
# Parent 0be0dffb7a83d1a973a0913230223cfd456a3148
ui: rewrite configint in terms of configwith
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -453,17 +453,11 @@ class ui(object):
>>> 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
diff --git a/tests/test-convert-git.t b/tests/test-convert-git.t
--- a/tests/test-convert-git.t
+++ b/tests/test-convert-git.t
@@ -330,7 +330,7 @@ since bar is not touched in this commit,
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
More information about the Mercurial-devel
mailing list