# HG changeset patch # User Thomas Arendsen Hein # Date 1182969453 -7200 # Node ID b0520e3903fe737af4cd90bfb637948a4d2d8316 # Parent 1d5a2ee683b0cae02704d089472d9b7810d91a7b Disallow short earlygetop option combined with other short options While "hg commit -qRfoo" can be read as "--quiet --repository foo", "hg commit -mRfoo" should be "--message Rfoo". diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -263,22 +263,16 @@ def earlygetopt(aliases, args): while pos < argcount: valuepos = argcount for opt in aliases: - # short option can have no spaces, e.g. hg log -qRfoo: + # short option can have no following space, e.g. hg log -Rfoo: if len(opt) == 2: i = argcount while i > 0: i -= 1 arg = args[i] - if len(arg) > 2 and arg[0] == '-' and arg[1] != '-': - optpos = arg.find(opt[1]) - # split Rfoo -> R foo - if 0 < optpos < len(arg)-1: - args[i:i+1] = [arg[:optpos+1], arg[optpos+1:]] - argcount += 1 - # split -qR -> -q -R - if optpos > 1: - args[i:i+1] = [arg[:optpos], opt] - argcount += 1 + if len(arg) > 2 and arg.startswith(opt): + # split -Rfoo -> -R foo + args[i:i+1] = [opt, arg[2:]] + argcount += 1 # find next occurance of current alias try: candidate = args.index(opt, pos, argcount) + 1 diff --git a/tests/test-globalopts b/tests/test-globalopts --- a/tests/test-globalopts +++ b/tests/test-globalopts @@ -32,10 +32,8 @@ echo "%% earlygetopt with duplicate opti hg --cwd a --cwd b --cwd c tip hg --repo c --repository b -R a tip -echo "%% earlygetopt short option without spaces (79cc512a34ed)" -hg -qR a tip +echo "%% earlygetopt short option without following space" hg -q -Rb tip -hg -qRc tip echo %% --cwd hg --cwd a parents diff --git a/tests/test-globalopts.out b/tests/test-globalopts.out --- a/tests/test-globalopts.out +++ b/tests/test-globalopts.out @@ -46,10 +46,8 @@ user: test date: Thu Jan 01 00:00:01 1970 +0000 summary: a -%% earlygetopt short option without spaces (79cc512a34ed) -0:8580ff50825a +%% earlygetopt short option without following space 0:b6c483daf290 -1:b6c483daf290 %% --cwd changeset: 0:8580ff50825a tag: tip