Mercurial > hg
changeset 4732:b0520e3903fe
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".
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Wed, 27 Jun 2007 20:37:33 +0200 |
parents | 1d5a2ee683b0 |
children | 0ecfc3b3f072 |
files | mercurial/cmdutil.py tests/test-globalopts tests/test-globalopts.out |
diffstat | 3 files changed, 7 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Wed Jun 27 08:35:26 2007 -0700 +++ b/mercurial/cmdutil.py Wed Jun 27 20:37:33 2007 +0200 @@ -263,22 +263,16 @@ 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
--- a/tests/test-globalopts Wed Jun 27 08:35:26 2007 -0700 +++ b/tests/test-globalopts Wed Jun 27 20:37:33 2007 +0200 @@ -32,10 +32,8 @@ 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
--- a/tests/test-globalopts.out Wed Jun 27 08:35:26 2007 -0700 +++ b/tests/test-globalopts.out Wed Jun 27 20:37:33 2007 +0200 @@ -46,10 +46,8 @@ 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