Mercurial > hg
changeset 21288:eb6eaef7ae44
help: provide a more helpful message when no keyword are matched
Before this changeset, when no topic were matching the provided keyword ( in
command such as `hg help --keyword babar`) the output was empty. This is
confusing and unhelpful for new users seeking assistance in the help.
We now display:
$ hg help --keyword babar
abort: no matches
(try "hg help" for a list of topics)
This send users in a new direction where they may find what they are looking for.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 16 Apr 2014 20:01:03 -0400 |
parents | 2d93b74335a2 |
children | c3784e3c3e8d |
files | mercurial/help.py tests/test-help.t |
diffstat | 2 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/help.py Tue Apr 29 11:40:42 2014 -0700 +++ b/mercurial/help.py Wed Apr 16 20:01:03 2014 -0400 @@ -481,6 +481,10 @@ rst.append('%s:\n\n' % title) rst.extend(minirst.maketable(sorted(matches[t]), 1)) rst.append('\n') + if not rst: + msg = _('no matches') + hint = _('try "hg help" for a list of topics') + raise util.Abort(msg, hint=hint) elif name and name != 'shortlist': i = None if unknowncmd:
--- a/tests/test-help.t Tue Apr 29 11:40:42 2014 -0700 +++ b/tests/test-help.t Wed Apr 16 20:01:03 2014 -0400 @@ -988,6 +988,13 @@ qclone clone main and patch repository at same time +Test unfound keyword + + $ hg help --keyword nonexistingwordthatwillneverexisteverever + abort: no matches + (try "hg help" for a list of topics) + [255] + Test omit indicating for help $ cat > addverboseitems.py <<EOF