comparison 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
comparison
equal deleted inserted replaced
24221:4e240d6ab898 24222:02d7b5cd373b
218 try: 218 try:
219 # check if the command is in a disabled extension 219 # check if the command is in a disabled extension
220 # (but don't check for extensions themselves) 220 # (but don't check for extensions themselves)
221 commands.help_(ui, inst.args[0], unknowncmd=True) 221 commands.help_(ui, inst.args[0], unknowncmd=True)
222 except error.UnknownCommand: 222 except error.UnknownCommand:
223 commands.help_(ui, 'shortlist') 223 suggested = False
224 if len(inst.args) == 2:
225 sim = _getsimilar(inst.args[1], inst.args[0])
226 if sim:
227 ui.warn(_('(did you mean one of %s?)\n') %
228 ', '.join(sorted(sim)))
229 suggested = True
230 if not suggested:
231 commands.help_(ui, 'shortlist')
224 except error.InterventionRequired, inst: 232 except error.InterventionRequired, inst:
225 ui.warn("%s\n" % inst) 233 ui.warn("%s\n" % inst)
226 return 1 234 return 1
227 except util.Abort, inst: 235 except util.Abort, inst:
228 ui.warn(_("abort: %s\n") % inst) 236 ui.warn(_("abort: %s\n") % inst)