changeset 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 691524f0bbf6
children 7f8f9f0369ca
files mercurial/dispatch.py tests/test-bookmarks-pushpull.t tests/test-dispatch.t tests/test-setdiscovery.t
diffstat 4 files changed, 20 insertions(+), 3 deletions(-) [+]
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:
--- a/tests/test-bookmarks-pushpull.t	Sat Nov 04 20:07:40 2017 +0900
+++ b/tests/test-bookmarks-pushpull.t	Sat Nov 11 12:09:19 2017 +0900
@@ -175,7 +175,7 @@
      Z                         1:0d2164f0ce0d
 
   $ cd ../b
-  $ hg up --config
+  $ hg up
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   updating bookmark foobar
   $ echo c2 > f2
--- a/tests/test-dispatch.t	Sat Nov 04 20:07:40 2017 +0900
+++ b/tests/test-dispatch.t	Sat Nov 11 12:09:19 2017 +0900
@@ -30,6 +30,18 @@
   (use 'hg cat -h' to show more help)
   [255]
 
+Missing parameter for early option:
+
+  $ hg log -R 2>&1 | grep 'hg log'
+  hg log: option -R requires argument
+  hg log [OPTION]... [FILE]
+  (use 'hg log -h' to show more help)
+
+  $ hg log -R -- 2>&1 | grep 'hg log'
+  hg log: option -R requires argument
+  hg log [OPTION]... [FILE]
+  (use 'hg log -h' to show more help)
+
 [defaults]
 
   $ hg cat a
--- a/tests/test-setdiscovery.t	Sat Nov 04 20:07:40 2017 +0900
+++ b/tests/test-setdiscovery.t	Sat Nov 11 12:09:19 2017 +0900
@@ -17,7 +17,7 @@
   >     hg -R a debugdiscovery b --verbose --debug --config progress.debug=true
   >     echo
   >     echo "% -- b -> a tree"
-  >     hg -R b debugdiscovery a --verbose --old --config
+  >     hg -R b debugdiscovery a --verbose --old
   >     echo
   >     echo "% -- b -> a set"
   >     hg -R b debugdiscovery a --verbose --debug --config progress.debug=true