Improved error message for ambiguous command shortcuts.
--- 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')