##// 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 5 # This software may be used and distributed according to the terms of the
6 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 11 def gnugetopt(args, options, longoptions):
11 12 """Parse options mostly like getopt.gnu_getopt.
@@ -105,7 +106,11 b' def fancyopts(args, options, state, gnu='
105 106 if t is type(fancyopts):
106 107 state[name] = defmap[name](val)
107 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 114 elif t is type(''):
110 115 state[name] = val
111 116 elif t is type([]):
@@ -602,6 +602,9 b' test -p0'
602 602 $ echo a > a
603 603 $ hg ci -Am t
604 604 adding a
605 $ hg import -p foo
606 abort: invalid value 'foo' for option -p, expected int
607 [255]
605 608 $ hg import -p0 - << EOF
606 609 > foobar
607 610 > --- a Sat Apr 12 22:43:58 2008 -0400
General Comments 0
You need to be logged in to leave comments. Login now