Mercurial > hg-stable
diff mercurial/dispatch.py @ 24222:02d7b5cd373b
dispatch: offer suggestions of similar-named commands
When suggestions are available, we show those suggestions instead of
showing some help output.
author | Augie Fackler <augie@google.com> |
---|---|
date | Tue, 10 Feb 2015 15:59:12 -0500 |
parents | 4e240d6ab898 |
children | b76d8c641746 |
line wrap: on
line diff
--- a/mercurial/dispatch.py Mon Jan 26 15:43:13 2015 -0500 +++ b/mercurial/dispatch.py Tue Feb 10 15:59:12 2015 -0500 @@ -220,7 +220,15 @@ # (but don't check for extensions themselves) commands.help_(ui, inst.args[0], unknowncmd=True) except error.UnknownCommand: - commands.help_(ui, 'shortlist') + suggested = False + if len(inst.args) == 2: + sim = _getsimilar(inst.args[1], inst.args[0]) + if sim: + ui.warn(_('(did you mean one of %s?)\n') % + ', '.join(sorted(sim))) + suggested = True + if not suggested: + commands.help_(ui, 'shortlist') except error.InterventionRequired, inst: ui.warn("%s\n" % inst) return 1