diff mercurial/dispatch.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 18a9fbb5cd78
children da1658d63647
line wrap: on
line diff
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -238,6 +238,7 @@ def _earlygetopt(aliases, args):
             pos += 1
     return values
 
+_loaded = {}
 def _dispatch(ui, args):
     # read --config before doing anything else
     # (e.g. to change trust settings for reading .hg/hgrc)
@@ -269,6 +270,16 @@ def _dispatch(ui, args):
         lui.readconfig(os.path.join(path, ".hg", "hgrc"))
 
     extensions.loadall(lui)
+    for name, module in extensions.extensions():
+        if name in _loaded:
+            continue
+        cmdtable = getattr(module, 'cmdtable', {})
+        overrides = [cmd for cmd in cmdtable if cmd in commands.table]
+        if overrides:
+            ui.warn(_("extension '%s' overrides commands: %s\n")
+                    % (name, " ".join(overrides)))
+        commands.table.update(cmdtable)
+        _loaded[name] = 1
     # check for fallback encoding
     fallback = lui.config('ui', 'fallbackencoding')
     if fallback: