Skip to content
Snippets Groups Projects
Commit c4717f44c1f1 authored by Idan Kamara's avatar Idan Kamara
Browse files

fancyopts: don't show a traceback on invalid integer values

parent cf204e9829f4
No related branches found
No related tags found
No related merge requests found
......@@ -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([]):
......
......@@ -602,6 +602,9 @@
$ echo a > a
$ hg ci -Am t
adding a
$ hg import -p foo
abort: invalid value 'foo' for option -p, expected int
[255]
$ hg import -p0 - << EOF
> foobar
> --- a Sat Apr 12 22:43:58 2008 -0400
......
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