# HG changeset patch # User TK Soh # Date 1141715117 -3600 # Node ID bb70ffebe77b222df4164e0e05a23729b509eea4 # Parent 4d2791f4ef803c5a1a72ecd23392155a76be3292 show choices on ambiguous commands diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2678,23 +2678,22 @@ norepo = ("clone init version help debug def find(cmd): """Return (aliases, command table entry) for command string.""" - choice = None - count = 0 + choice = [] for e in table.keys(): aliases = e.lstrip("^").split("|") if cmd in aliases: return aliases, table[e] for a in aliases: if a.startswith(cmd): - count += 1 - choice = aliases, table[e] + choice.append([aliases, table[e]]) break - if count > 1: - raise AmbiguousCommand(cmd) + if len(choice) > 1: + clist = [x[0][0] for x in choice] + raise AmbiguousCommand(cmd, clist) if choice: - return choice + return choice[0] raise UnknownCommand(cmd) @@ -2806,7 +2805,8 @@ def dispatch(args): help_(u, 'shortlist') sys.exit(-1) except AmbiguousCommand, inst: - u.warn(_("hg: command '%s' is ambiguous.\n") % inst.args[0]) + u.warn(_("hg: command '%s' is ambiguous:\n %s\n") % + (inst.args[0], " ".join(inst.args[1]))) sys.exit(1) except UnknownCommand, inst: u.warn(_("hg: unknown command '%s'\n") % inst.args[0]) @@ -2941,7 +2941,8 @@ def dispatch(args): u.warn(_("%s: invalid arguments\n") % cmd) help_(u, cmd) except AmbiguousCommand, inst: - u.warn(_("hg: command '%s' is ambiguous.\n") % inst.args[0]) + u.warn(_("hg: command '%s' is ambiguous:\n %s\n") % + (inst.args[0], " ".join(inst.args[1]))) help_(u, 'shortlist') except UnknownCommand, inst: u.warn(_("hg: unknown command '%s'\n") % inst.args[0])