mercurial/fancyopts.py
changeset 26587 56b2bcea2529
parent 25947 6002e2d95e54
child 29947 e1f0ec0b7d2d
equal deleted inserted replaced
26586:d51c658d3f04 26587:56b2bcea2529
     8 from __future__ import absolute_import
     8 from __future__ import absolute_import
     9 
     9 
    10 import getopt
    10 import getopt
    11 
    11 
    12 from .i18n import _
    12 from .i18n import _
    13 from . import util
    13 from . import error
    14 
    14 
    15 def gnugetopt(args, options, longoptions):
    15 def gnugetopt(args, options, longoptions):
    16     """Parse options mostly like getopt.gnu_getopt.
    16     """Parse options mostly like getopt.gnu_getopt.
    17 
    17 
    18     This is different from getopt.gnu_getopt in that an argument of - will
    18     This is different from getopt.gnu_getopt in that an argument of - will
   112             state[name] = defmap[name](val)
   112             state[name] = defmap[name](val)
   113         elif t is type(1):
   113         elif t is type(1):
   114             try:
   114             try:
   115                 state[name] = int(val)
   115                 state[name] = int(val)
   116             except ValueError:
   116             except ValueError:
   117                 raise util.Abort(_('invalid value %r for option %s, '
   117                 raise error.Abort(_('invalid value %r for option %s, '
   118                                    'expected int') % (val, opt))
   118                                    'expected int') % (val, opt))
   119         elif t is type(''):
   119         elif t is type(''):
   120             state[name] = val
   120             state[name] = val
   121         elif t is type([]):
   121         elif t is type([]):
   122             state[name].append(val)
   122             state[name].append(val)