diff mercurial/dispatch.py @ 35027:7384250eabd9 stable

dispatch: do not drop unpaired argument at _earlygetopt() Before, "hg log -R" just worked.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 11 Nov 2017 12:09:19 +0900
parents fe987d0b9e1e
children 7f8f9f0369ca
line wrap: on
line diff
--- a/mercurial/dispatch.py	Sat Nov 04 20:07:40 2017 +0900
+++ b/mercurial/dispatch.py	Sat Nov 11 12:09:19 2017 +0900
@@ -661,6 +661,10 @@
     >>> args = [b'x', b'-Rbar', 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'])
     """
     try:
         argcount = args.index("--")
@@ -675,14 +679,15 @@
         if equals > -1:
             arg = arg[:equals]
         if arg in aliases:
-            del args[pos]
             if equals > -1:
+                del args[pos]
                 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
+                del args[pos]
                 values.append(args.pop(pos))
                 argcount -= 2
         elif arg[:2] in shortopts: