# HG changeset patch # User Bryan O'Sullivan # Date 1367270082 25200 # Node ID fc081623f4bd918e384b47231707a4ee71dc1ccf # Parent f01ae031f84c41811aa7c1d725236b2d878e2183 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! diff -r f01ae031f84c -r fc081623f4bd mercurial/dispatch.py --- a/mercurial/dispatch.py Mon Apr 29 14:14:41 2013 -0700 +++ b/mercurial/dispatch.py Mon Apr 29 14:14:42 2013 -0700 @@ -490,6 +490,10 @@ >>> _earlygetopt(['--cwd'], args), args (['foo'], ['x', 'y']) + >>> args = ['x', '--cwd=bar', 'y'] + >>> _earlygetopt(['--cwd'], args), args + (['bar'], ['x', 'y']) + >>> args = ['x', '-R', 'foo', 'y'] >>> _earlygetopt(['-R'], args), args (['foo'], ['x', 'y']) @@ -506,14 +510,22 @@ values = [] pos = 0 while pos < argcount: - if args[pos] in aliases: - if pos + 1 >= argcount: - # ignore and let getopt report an error if there is no value - break + fullarg = arg = args[pos] + equals = arg.find('=') + if equals > -1: + arg = arg[:equals] + if arg in aliases: del args[pos] - values.append(args.pop(pos)) - argcount -= 2 - elif args[pos][:2] in shortopts: + if equals > -1: + values.append(fullarg[equals + 1:]) + 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 values.append(args.pop(pos)[2:]) argcount -= 1