comparison mercurial/dispatch.py @ 10364:de1e7099d100

dispatch: provide help for disabled extensions and commands Before a command is declared unknown, each extension in hgext is searched, starting with hgext.<cmdname>. If there's a matching command, a help message suggests the appropriate extension and how to enable it. Every extension could potentially be imported, but for cases like rebase, relink, etc. only one extension is imported. For the case of "hg help disabledext", if the extension is in hgext, the extension description is read and a similar help suggestion is printed. No extension import occurs.
author Brodie Rao <me+hg@dackz.net>
date Sun, 07 Feb 2010 14:01:43 +0100
parents 08a0f04b56bd
children d216fa04e48a
comparison
equal deleted inserted replaced
10363:c07974215b3d 10364:de1e7099d100
91 ui.warn(_("abort: %s!\n") % inst) 91 ui.warn(_("abort: %s!\n") % inst)
92 except error.SignalInterrupt: 92 except error.SignalInterrupt:
93 ui.warn(_("killed!\n")) 93 ui.warn(_("killed!\n"))
94 except error.UnknownCommand, inst: 94 except error.UnknownCommand, inst:
95 ui.warn(_("hg: unknown command '%s'\n") % inst.args[0]) 95 ui.warn(_("hg: unknown command '%s'\n") % inst.args[0])
96 commands.help_(ui, 'shortlist') 96 try:
97 # check if the command is in a disabled extension
98 # (but don't check for extensions themselves)
99 commands.help_(ui, inst.args[0], unknowncmd=True)
100 except error.UnknownCommand:
101 commands.help_(ui, 'shortlist')
97 except util.Abort, inst: 102 except util.Abort, inst:
98 ui.warn(_("abort: %s\n") % inst) 103 ui.warn(_("abort: %s\n") % inst)
99 except ImportError, inst: 104 except ImportError, inst:
100 m = str(inst).split()[-1] 105 m = str(inst).split()[-1]
101 ui.warn(_("abort: could not import module %s!\n") % m) 106 ui.warn(_("abort: could not import module %s!\n") % m)
216 221
217 except error.UnknownCommand: 222 except error.UnknownCommand:
218 def fn(ui, *args): 223 def fn(ui, *args):
219 ui.warn(_("alias '%s' resolves to unknown command '%s'\n") \ 224 ui.warn(_("alias '%s' resolves to unknown command '%s'\n") \
220 % (self.name, cmd)) 225 % (self.name, cmd))
226 try:
227 # check if the command is in a disabled extension
228 commands.help_(ui, cmd, unknowncmd=True)
229 except error.UnknownCommand:
230 pass
221 return 1 231 return 1
222 self.fn = fn 232 self.fn = fn
223 self.badalias = True 233 self.badalias = True
224 except error.AmbiguousCommand: 234 except error.AmbiguousCommand:
225 def fn(ui, *args): 235 def fn(ui, *args):