comparison mercurial/cmdutil.py @ 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 79cc512a34ed
children 0ecfc3b3f072
comparison
equal deleted inserted replaced
4731:1d5a2ee683b0 4732:b0520e3903fe
261 values = [] 261 values = []
262 pos = 0 262 pos = 0
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: 275 argcount += 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
282 # find next occurance of current alias 276 # find next occurance of current alias
283 try: 277 try:
284 candidate = args.index(opt, pos, argcount) + 1 278 candidate = args.index(opt, pos, argcount) + 1
285 # ignore and let getopt report an error if there is no value 279 # ignore and let getopt report an error if there is no value
286 if candidate < valuepos: 280 if candidate < valuepos: