changeset 1518:ac4ca6bf2383

Improved error message for ambiguous command shortcuts.
author Thomas Arendsen Hein <thomas@intevation.de>
date Mon, 07 Nov 2005 19:00:51 +0100
parents b582dbc16165
children 5b19dea9d4fd
files mercurial/commands.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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')