diff mercurial/extensions.py @ 5189:60acf1432ee0

Move cmdtable and reposetup handling out of extensions.py A new function (extensions.extensions) allows the code that is interested in those attributes to handle them directly. This allows some cleanups of extensions.py. Notably, we can remove the extensions.commandtable hack. It also makes it easier to add standard extension attributes, like a "hgwebsetup" function or a "helptable" dict that augments the data in help.py, etc.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Fri, 17 Aug 2007 17:33:27 -0300
parents 4f648e95caca
children b12432b1c2c7
line wrap: on
line diff
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -10,8 +10,13 @@ import util, sys
 from i18n import _
 
 _extensions = {}
-commandtable = {}
-setuphooks = []
+_order = []
+
+def extensions():
+    for name in _order:
+        module = _extensions[name]
+        if module:
+            yield name, module
 
 def find(name):
     '''return module with given extension name'''
@@ -55,19 +60,11 @@ def load(ui, name, path):
         except ImportError:
             mod = importh(name)
     _extensions[shortname] = mod
+    _order.append(shortname)
 
     uisetup = getattr(mod, 'uisetup', None)
     if uisetup:
         uisetup(ui)
-    reposetup = getattr(mod, 'reposetup', None)
-    if reposetup:
-        setuphooks.append(reposetup)
-    cmdtable = getattr(mod, 'cmdtable', {})
-    overrides = [cmd for cmd in cmdtable if cmd in commandtable]
-    if overrides:
-        ui.warn(_("extension '%s' overrides commands: %s\n")
-                % (name, " ".join(overrides)))
-    commandtable.update(cmdtable)
 
 def loadall(ui):
     result = ui.configitems("extensions")