--- a/mercurial/cmdutil.py Tue Jun 26 15:28:17 2007 +0200
+++ b/mercurial/cmdutil.py Tue Jun 26 18:35:31 2007 +0200
@@ -248,7 +248,12 @@
return parsed
def earlygetopt(aliases, args):
- """Return list of values for a option (with aliases) in given order"""
+ """Return list of values for a option (with aliases) in given order
+
+ Short option aliases have to occur before long aliases, e.g.:
+ earlygetopt(["-R", "--repository", "--repo"], args)
+ (this is not checked!)
+ """
try:
argcount = args.index("--")
except ValueError:
@@ -258,6 +263,22 @@
while pos < argcount:
valuepos = argcount
for opt in aliases:
+ # short option can have no spaces, e.g. hg log -qRfoo:
+ 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
# find next occurance of current alias
try:
candidate = args.index(opt, pos, argcount) + 1