##// END OF EJS Templates
dispatch: make loading extra information from extension extensible...
FUJIWARA Katsunori -
r28391:73905484 default
parent child Browse files
Show More
@@ -7147,3 +7147,12 b' def version_(ui):'
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)
@@ -743,6 +743,17 b' def _checkshellalias(lui, ui, args, prec'
743 [], {})
743 [], {})
744
744
745 _loaded = set()
745 _loaded = set()
746
747 # list of (objname, loadermod, loadername) tuple:
748 # - objname is the name of an object in extension module, from which
749 # extra information is loaded
750 # - loadermod is the module where loader is placed
751 # - loadername is the name of the function, which takes (ui, extensionname,
752 # extraobj) arguments
753 extraloaders = [
754 ('cmdtable', commands, 'loadcmdtable'),
755 ]
756
746 def _dispatch(req):
757 def _dispatch(req):
747 args = req.args
758 args = req.args
748 ui = req.ui
759 ui = req.ui
@@ -772,12 +783,10 b' def _dispatch(req):'
772 # (uisetup and extsetup are handled in extensions.loadall)
783 # (uisetup and extsetup are handled in extensions.loadall)
773
784
774 for name, module in exts:
785 for name, module in exts:
775 cmdtable = getattr(module, 'cmdtable', {})
786 for objname, loadermod, loadername in extraloaders:
776 overrides = [cmd for cmd in cmdtable if cmd in commands.table]
787 extraobj = getattr(module, objname, None)
777 if overrides:
788 if extraobj is not None:
778 ui.warn(_("extension '%s' overrides commands: %s\n")
789 getattr(loadermod, loadername)(ui, name, extraobj)
779 % (name, " ".join(overrides)))
780 commands.table.update(cmdtable)
781 _loaded.add(name)
790 _loaded.add(name)
782
791
783 # (reposetup is handled in hg.repository)
792 # (reposetup is handled in hg.repository)
General Comments 0
You need to be logged in to leave comments. Login now