dispatch: fix early parsing of short option with value like -R=foo stable
authorYuya Nishihara <yuya@tcha.org>
Tue, 14 Nov 2017 00:25:59 +0900
branchstable
changeset 34983 e273b6671827
parent 34982 d9aba3730d30
child 34984 cd235d6f851b
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.
mercurial/dispatch.py
--- 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: