mercurial/parser.py
branchstable
changeset 42162 29798c9ba5c9
parent 39087 0a2ce5b43574
child 43076 2372284d9457
equal deleted inserted replaced
42161:724dae82c4bd 42162:29798c9ba5c9
   145 
   145 
   146     Invalid keywords, too few positional arguments, or too many positional
   146     Invalid keywords, too few positional arguments, or too many positional
   147     arguments are rejected, but missing keyword arguments are just omitted.
   147     arguments are rejected, but missing keyword arguments are just omitted.
   148     """
   148     """
   149     poskeys, varkey, keys, optkey = argspec
   149     poskeys, varkey, keys, optkey = argspec
   150     kwstart = next((i for i, x in enumerate(trees) if x[0] == keyvaluenode),
   150     kwstart = next((i for i, x in enumerate(trees)
       
   151                     if x and x[0] == keyvaluenode),
   151                    len(trees))
   152                    len(trees))
   152     if kwstart < len(poskeys):
   153     if kwstart < len(poskeys):
   153         raise error.ParseError(_("%(func)s takes at least %(nargs)d positional "
   154         raise error.ParseError(_("%(func)s takes at least %(nargs)d positional "
   154                                  "arguments")
   155                                  "arguments")
   155                                % {'func': funcname, 'nargs': len(poskeys)})
   156                                % {'func': funcname, 'nargs': len(poskeys)})
   169             args[k] = x
   170             args[k] = x
   170     # remainder should be keyword arguments
   171     # remainder should be keyword arguments
   171     if optkey:
   172     if optkey:
   172         args[optkey] = util.sortdict()
   173         args[optkey] = util.sortdict()
   173     for x in trees[kwstart:]:
   174     for x in trees[kwstart:]:
   174         if x[0] != keyvaluenode or x[1][0] != keynode:
   175         if not x or x[0] != keyvaluenode or x[1][0] != keynode:
   175             raise error.ParseError(_("%(func)s got an invalid argument")
   176             raise error.ParseError(_("%(func)s got an invalid argument")
   176                                    % {'func': funcname})
   177                                    % {'func': funcname})
   177         k = x[1][1]
   178         k = x[1][1]
   178         if k in keys:
   179         if k in keys:
   179             d = args
   180             d = args