comparison mercurial/commands.py @ 28391:73905484ef70

dispatch: make loading extra information from extension extensible This patch makes loading extra information from extension module at dispatching extensible. Factoring 'loadcmdtable()' into commands.py is a part of generalization of loading extra information. This extensibility assumes registration of new function like below, for example: - revset predicate - fileset predicate - template keyword - template filter - template function - internal merge tool - web command This patch requires not loader function itself but container module and the name of it, because listing loader function directly up implies actual loading module of it, even if it isn't used at runtime (for example, extensions don't always define revset predicate)
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 08 Mar 2016 23:04:53 +0900
parents f6b5b041c6c9
children 7f77e71e5d7e
comparison
equal deleted inserted replaced
28386:1c658391b22f 28391:73905484ef70
7145 if names: 7145 if names:
7146 maxnamelen = max(len(n) for n in names) 7146 maxnamelen = max(len(n) for n in names)
7147 for i, name in enumerate(names): 7147 for i, name in enumerate(names):
7148 ui.write(" %-*s %s %s\n" % 7148 ui.write(" %-*s %s %s\n" %
7149 (maxnamelen, name, place[i], vers[i])) 7149 (maxnamelen, name, place[i], vers[i]))
7150
7151 def loadcmdtable(ui, name, cmdtable):
7152 """Load command functions from specified cmdtable
7153 """
7154 overrides = [cmd for cmd in cmdtable if cmd in table]
7155 if overrides:
7156 ui.warn(_("extension '%s' overrides commands: %s\n")
7157 % (name, " ".join(overrides)))
7158 table.update(cmdtable)