Mercurial > public > mercurial-scm > hg
diff mercurial/fancyopts.py @ 17712:c4717f44c1f1
fancyopts: don't show a traceback on invalid integer values
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Mon, 08 Oct 2012 15:35:16 +0200 |
parents | d3bb825ddae3 |
children | 1e5b38a919dd |
line wrap: on
line diff
--- a/mercurial/fancyopts.py Wed Oct 03 22:09:18 2012 +0200 +++ b/mercurial/fancyopts.py Mon Oct 08 15:35:16 2012 +0200 @@ -5,7 +5,8 @@ # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. -import getopt +import getopt, util +from i18n import _ def gnugetopt(args, options, longoptions): """Parse options mostly like getopt.gnu_getopt. @@ -105,7 +106,11 @@ if t is type(fancyopts): state[name] = defmap[name](val) elif t is type(1): - state[name] = int(val) + try: + state[name] = int(val) + except ValueError: + raise util.Abort(_('invalid value %r for option %s, ' + 'expected int') % (val, opt)) elif t is type(''): state[name] = val elif t is type([]):