# HG changeset patch # User Thomas Arendsen Hein # Date 1131386451 -3600 # Node ID ac4ca6bf23836a4f9ec6ba318f6843e3404681f4 # Parent b582dbc161655aa19f5237f9c60516d2fc361909 Improved error message for ambiguous command shortcuts. diff -r b582dbc16165 -r ac4ca6bf2383 mercurial/commands.py --- a/mercurial/commands.py Mon Nov 07 18:39:25 2005 +0100 +++ b/mercurial/commands.py Mon Nov 07 19:00:51 2005 +0100 @@ -15,6 +15,8 @@ class UnknownCommand(Exception): """Exception raised if command is not in the command table.""" +class AmbiguousCommand(Exception): + """Exception raised if command shortcut matches more than one command.""" def filterfiles(filters, files): l = [x for x in files if x in filters] @@ -2382,7 +2384,7 @@ for a in aliases: if a.startswith(cmd): if choice: - raise UnknownCommand(cmd) + raise AmbiguousCommand(cmd) else: choice = aliases, table[e] if choice: @@ -2505,6 +2507,9 @@ u.warn(_("hg: %s\n") % inst.args[1]) help_(u, 'shortlist') sys.exit(-1) + except AmbiguousCommand, inst: + u.warn(_("hg: command '%s' is ambiguous.\n") % inst.args[0]) + sys.exit(1) except UnknownCommand, inst: u.warn(_("hg: unknown command '%s'\n") % inst.args[0]) help_(u, 'shortlist')