# HG changeset patch # User Thomas Arendsen Hein # Date 1131385165 -3600 # Node ID b582dbc161655aa19f5237f9c60516d2fc361909 # Parent b254243b71595549519a558b1e134a6312235480 Canonicalize command when using aliases or prefix matching. This makes the norepo check and the help and version command work when not using the canonical name. diff -r b254243b7159 -r b582dbc16165 mercurial/commands.py --- a/mercurial/commands.py Fri Nov 04 11:37:45 2005 -0800 +++ b/mercurial/commands.py Mon Nov 07 18:39:25 2005 +0100 @@ -387,7 +387,7 @@ if with_version: show_version(ui) ui.write('\n') - key, i = find(cmd) + aliases, i = find(cmd) # synopsis ui.write("%s\n\n" % i[2]) @@ -399,9 +399,8 @@ if not ui.quiet: # aliases - aliases = ', '.join(key.split('|')[1:]) - if aliases: - ui.write(_("\naliases: %s\n") % aliases) + if len(aliases) > 1: + ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:])) # options if i[1]: @@ -2374,17 +2373,20 @@ " debugindex debugindexdot paths") def find(cmd): - choice = [] + """Return (aliases, command table entry) for command string.""" + choice = None for e in table.keys(): aliases = e.lstrip("^").split("|") if cmd in aliases: - return e, table[e] + return aliases, table[e] for a in aliases: if a.startswith(cmd): - choice.append(e) - if len(choice) == 1: - e = choice[0] - return e, table[e] + if choice: + raise UnknownCommand(cmd) + else: + choice = aliases, table[e] + if choice: + return choice raise UnknownCommand(cmd) @@ -2422,7 +2424,8 @@ cmd, args = args[0], args[1:] - i = find(cmd)[1] + aliases, i = find(cmd) + cmd = aliases[0] c = list(i[1]) else: cmd = None