##// END OF EJS Templates
Disallow short earlygetop option combined with other short options...
Thomas Arendsen Hein -
r4732:b0520e39 default
parent child Browse files
Show More
@@ -263,21 +263,15 b' def earlygetopt(aliases, args):'
263 while pos < argcount:
263 while pos < argcount:
264 valuepos = argcount
264 valuepos = argcount
265 for opt in aliases:
265 for opt in aliases:
266 # short option can have no spaces, e.g. hg log -qRfoo:
266 # short option can have no following space, e.g. hg log -Rfoo:
267 if len(opt) == 2:
267 if len(opt) == 2:
268 i = argcount
268 i = argcount
269 while i > 0:
269 while i > 0:
270 i -= 1
270 i -= 1
271 arg = args[i]
271 arg = args[i]
272 if len(arg) > 2 and arg[0] == '-' and arg[1] != '-':
272 if len(arg) > 2 and arg.startswith(opt):
273 optpos = arg.find(opt[1])
273 # split -Rfoo -> -R foo
274 # split Rfoo -> R foo
274 args[i:i+1] = [opt, arg[2:]]
275 if 0 < optpos < len(arg)-1:
276 args[i:i+1] = [arg[:optpos+1], arg[optpos+1:]]
277 argcount += 1
278 # split -qR -> -q -R
279 if optpos > 1:
280 args[i:i+1] = [arg[:optpos], opt]
281 argcount += 1
275 argcount += 1
282 # find next occurance of current alias
276 # find next occurance of current alias
283 try:
277 try:
@@ -32,10 +32,8 b' echo "%% earlygetopt with duplicate opti'
32 hg --cwd a --cwd b --cwd c tip
32 hg --cwd a --cwd b --cwd c tip
33 hg --repo c --repository b -R a tip
33 hg --repo c --repository b -R a tip
34
34
35 echo "%% earlygetopt short option without spaces (79cc512a34ed)"
35 echo "%% earlygetopt short option without following space"
36 hg -qR a tip
37 hg -q -Rb tip
36 hg -q -Rb tip
38 hg -qRc tip
39
37
40 echo %% --cwd
38 echo %% --cwd
41 hg --cwd a parents
39 hg --cwd a parents
@@ -46,10 +46,8 b' user: test'
46 date: Thu Jan 01 00:00:01 1970 +0000
46 date: Thu Jan 01 00:00:01 1970 +0000
47 summary: a
47 summary: a
48
48
49 %% earlygetopt short option without spaces (79cc512a34ed)
49 %% earlygetopt short option without following space
50 0:8580ff50825a
51 0:b6c483daf290
50 0:b6c483daf290
52 1:b6c483daf290
53 %% --cwd
51 %% --cwd
54 changeset: 0:8580ff50825a
52 changeset: 0:8580ff50825a
55 tag: tip
53 tag: tip
General Comments 0
You need to be logged in to leave comments. Login now