changeset 35031:e273b6671827 stable

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.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 14 Nov 2017 00:25:59 +0900
parents d9aba3730d30
children cd235d6f851b
files mercurial/dispatch.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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: