Mercurial > hg-stable
changeset 4727:79cc512a34ed
Fix earlygetop for short options with unnecessary spaces removed
Examples:
hg log -qR foo
hg log -Rfoo
hg log -qRfoo
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 26 Jun 2007 18:35:31 +0200 |
parents | f6e961c0155b |
children | 7bb5bcb089e3 |
files | mercurial/cmdutil.py |
diffstat | 1 files changed, 22 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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