--- a/mercurial/commands.py Sat Dec 05 23:16:09 2009 +0100
+++ b/mercurial/commands.py Sat Dec 05 23:26:27 2009 -0500
@@ -1486,6 +1486,11 @@
helplist(_('list of commands:\n\n'), select)
return
+ # check if it's an invalid alias and display its error if it is
+ if getattr(entry[0], 'badalias', False):
+ entry[0](ui)
+ return
+
# synopsis
if len(entry) > 2:
if entry[2].startswith('hg'):
--- a/mercurial/dispatch.py Sat Dec 05 23:16:09 2009 +0100
+++ b/mercurial/dispatch.py Sat Dec 05 23:26:27 2009 -0500
@@ -177,6 +177,7 @@
self.opts = []
self.help = ''
self.norepo = True
+ self.badalias = False
try:
cmdutil.findcmd(self.name, cmdtable, True)
@@ -189,6 +190,7 @@
ui.warn(_("no definition for alias '%s'\n") % self.name)
return 1
self.fn = fn
+ self.badalias = True
return
@@ -217,12 +219,14 @@
% (self.name, cmd))
return 1
self.fn = fn
+ self.badalias = True
except error.AmbiguousCommand:
def fn(ui, *args):
ui.warn(_("alias '%s' resolves to ambiguous command '%s'\n") \
% (self.name, cmd))
return 1
self.fn = fn
+ self.badalias = True
def __call__(self, ui, *args, **opts):
if self.shadows:
--- a/tests/test-alias Sat Dec 05 23:16:09 2009 +0100
+++ b/tests/test-alias Sat Dec 05 23:26:27 2009 -0500
@@ -25,15 +25,19 @@
echo '% unknown'
hg unknown
+hg help unknown
echo '% ambiguous'
hg ambiguous
+hg help ambiguous
echo '% recursive'
hg recursive
+hg help recursive
echo '% no definition'
hg nodef
+hg help nodef
cd alias
--- a/tests/test-alias.out Sat Dec 05 23:16:09 2009 +0100
+++ b/tests/test-alias.out Sat Dec 05 23:26:27 2009 -0500
@@ -1,12 +1,16 @@
% basic
% unknown
alias 'unknown' resolves to unknown command 'bargle'
+alias 'unknown' resolves to unknown command 'bargle'
% ambiguous
alias 'ambiguous' resolves to ambiguous command 's'
+alias 'ambiguous' resolves to ambiguous command 's'
% recursive
alias 'recursive' resolves to unknown command 'recursive'
+alias 'recursive' resolves to unknown command 'recursive'
% no definition
no definition for alias 'nodefinition'
+no definition for alias 'nodefinition'
% no usage
no rollback information available
adding foo