diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -486,7 +486,6 @@ def help_(ui, name, unknowncmd=False, fu hint = _('try "hg help" for a list of topics') raise util.Abort(msg, hint=hint) elif name and name != 'shortlist': - i = None if unknowncmd: queries = (helpextcmd,) elif opts.get('extension'): @@ -498,12 +497,16 @@ def help_(ui, name, unknowncmd=False, fu for f in queries: try: rst = f(name) - i = None break - except error.UnknownCommand, inst: - i = inst - if i: - raise i + except error.UnknownCommand: + pass + else: + if unknowncmd: + raise error.UnknownCommand(name) + else: + msg = _('no such help topic: %s') % name + hint = _('try "hg help --keyword %s"') % name + raise util.Abort(msg, hint=hint) else: # program name if not ui.quiet: diff --git a/tests/test-extension.t b/tests/test-extension.t --- a/tests/test-extension.t +++ b/tests/test-extension.t @@ -621,8 +621,8 @@ Broken disabled extension and command: > EOF $ hg --config extensions.path=./path.py help foo > /dev/null warning: error finding commands in $TESTTMP/hgext/forest.py (glob) - hg: unknown command 'foo' - warning: error finding commands in $TESTTMP/hgext/forest.py (glob) + abort: no such help topic: foo + (try "hg help --keyword foo") [255] $ cat > throw.py <