Mercurial > public > mercurial-scm > hg-stable
diff mercurial/help.py @ 21289:c3784e3c3e8d
help: suggest keyword search when no topic is found
When `hg help foobar` fails, it now suggests using `hg help --keyword foobar`
instead of printing a full page of basic commands.
This should greatly increases discoverability of the `hg help --keyword`
argument.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 16 Apr 2014 19:55:40 -0400 |
parents | eb6eaef7ae44 |
children | 8225bb1f0ad3 |
line wrap: on
line diff
--- a/mercurial/help.py Wed Apr 16 20:01:03 2014 -0400 +++ b/mercurial/help.py Wed Apr 16 19:55:40 2014 -0400 @@ -486,7 +486,6 @@ 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 @@ 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: