Skip to content
Snippets Groups Projects
Commit fc081623 authored by Bryan O'Sullivan's avatar Bryan O'Sullivan
Browse files

dispatch: add support for --option=value to _earlygetopt

This fixes a very confusing error message:

  $ hg --config=pager.enabled=off st
  abort: option --config may not be abbreviated!
parent f01ae031
No related branches found
No related tags found
No related merge requests found
...@@ -490,6 +490,10 @@ ...@@ -490,6 +490,10 @@
>>> _earlygetopt(['--cwd'], args), args >>> _earlygetopt(['--cwd'], args), args
(['foo'], ['x', 'y']) (['foo'], ['x', 'y'])
>>> args = ['x', '--cwd=bar', 'y']
>>> _earlygetopt(['--cwd'], args), args
(['bar'], ['x', 'y'])
>>> args = ['x', '-R', 'foo', 'y'] >>> args = ['x', '-R', 'foo', 'y']
>>> _earlygetopt(['-R'], args), args >>> _earlygetopt(['-R'], args), args
(['foo'], ['x', 'y']) (['foo'], ['x', 'y'])
...@@ -506,8 +510,9 @@ ...@@ -506,8 +510,9 @@
values = [] values = []
pos = 0 pos = 0
while pos < argcount: while pos < argcount:
if args[pos] in aliases: fullarg = arg = args[pos]
if pos + 1 >= argcount: equals = arg.find('=')
# ignore and let getopt report an error if there is no value if equals > -1:
break arg = arg[:equals]
if arg in aliases:
del args[pos] del args[pos]
...@@ -513,7 +518,14 @@ ...@@ -513,7 +518,14 @@
del args[pos] del args[pos]
values.append(args.pop(pos)) if equals > -1:
argcount -= 2 values.append(fullarg[equals + 1:])
elif args[pos][:2] in shortopts: argcount -= 1
else:
if pos + 1 >= argcount:
# ignore and let getopt report an error if there is no value
break
values.append(args.pop(pos))
argcount -= 2
elif arg[:2] in shortopts:
# short option can have no following space, e.g. hg log -Rfoo # short option can have no following space, e.g. hg log -Rfoo
values.append(args.pop(pos)[2:]) values.append(args.pop(pos)[2:])
argcount -= 1 argcount -= 1
......
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