dispatch: fix early parsing of short option with value like -R=foo
Before, -R=foo was parsed as '-R' 'foo', which disagrees with the standard
getopt behavior.
--- a/mercurial/dispatch.py Sat Nov 11 14:02:41 2017 +0900
+++ b/mercurial/dispatch.py Tue Nov 14 00:25:59 2017 +0900
@@ -665,6 +665,10 @@
>>> _earlygetopt([b'-R'], args), args
(['bar'], ['x', 'y'])
+ >>> args = [b'x', b'-R=bar', b'y']
+ >>> _earlygetopt([b'-R'], args), args
+ (['=bar'], ['x', 'y'])
+
>>> args = [b'x', b'-R', b'--', b'y']
>>> _earlygetopt([b'-R'], args), args
([], ['x', '-R', '--', 'y'])
@@ -678,7 +682,9 @@
pos = 0
while pos < argcount:
fullarg = arg = args[pos]
- equals = arg.find('=')
+ equals = -1
+ if arg.startswith('--'):
+ equals = arg.find('=')
if equals > -1:
arg = arg[:equals]
if arg in aliases: