##// END OF EJS Templates
fancyopts: don't show a traceback on invalid integer values
Idan Kamara -
r17712:c4717f44 default
parent child Browse files
Show More
@@ -5,7 +5,8 b''
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 import getopt
8 import getopt, util
9 from i18n import _
9
10
10 def gnugetopt(args, options, longoptions):
11 def gnugetopt(args, options, longoptions):
11 """Parse options mostly like getopt.gnu_getopt.
12 """Parse options mostly like getopt.gnu_getopt.
@@ -105,7 +106,11 b' def fancyopts(args, options, state, gnu='
105 if t is type(fancyopts):
106 if t is type(fancyopts):
106 state[name] = defmap[name](val)
107 state[name] = defmap[name](val)
107 elif t is type(1):
108 elif t is type(1):
108 state[name] = int(val)
109 try:
110 state[name] = int(val)
111 except ValueError:
112 raise util.Abort(_('invalid value %r for option %s, '
113 'expected int') % (val, opt))
109 elif t is type(''):
114 elif t is type(''):
110 state[name] = val
115 state[name] = val
111 elif t is type([]):
116 elif t is type([]):
@@ -602,6 +602,9 b' test -p0'
602 $ echo a > a
602 $ echo a > a
603 $ hg ci -Am t
603 $ hg ci -Am t
604 adding a
604 adding a
605 $ hg import -p foo
606 abort: invalid value 'foo' for option -p, expected int
607 [255]
605 $ hg import -p0 - << EOF
608 $ hg import -p0 - << EOF
606 > foobar
609 > foobar
607 > --- a Sat Apr 12 22:43:58 2008 -0400
610 > --- a Sat Apr 12 22:43:58 2008 -0400
General Comments 0
You need to be logged in to leave comments. Login now