color: do all setup in uisetup
authorMartin Geisler <mg@lazybytes.net>
Sat, 29 Aug 2009 00:30:03 +0200
changeset 9412 3a78bbc57660
parent 9411 8e6019b16a7d
child 9413 a5adf55ee533
color: do all setup in uisetup Now that extensions are loaded in phases, we are guaranteed to always find mq in uisetup with extensions.find and we know that the mq commands are not yet copied into commands.table.
hgext/color.py
--- a/hgext/color.py	Sun Aug 16 00:41:24 2009 +0200
+++ b/hgext/color.py	Sat Aug 29 00:30:03 2009 +0200
@@ -218,12 +218,8 @@
                  'changed': ['white'],
                  'trailingwhitespace': ['bold', 'red_background']}
 
-_ui = None
-
 def uisetup(ui):
     '''Initialize the extension.'''
-    global _ui
-    _ui = ui
     _setupcmd(ui, 'diff', commands.table, colordiff, _diff_effects)
     _setupcmd(ui, 'incoming', commands.table, None, _diff_effects)
     _setupcmd(ui, 'log', commands.table, None, _diff_effects)
@@ -231,17 +227,10 @@
     _setupcmd(ui, 'tip', commands.table, None, _diff_effects)
     _setupcmd(ui, 'status', commands.table, colorstatus, _status_effects)
 
-def extsetup():
     try:
         mq = extensions.find('mq')
-        try:
-            # If we are loaded after mq, we must wrap commands.table
-            _setupcmd(_ui, 'qdiff', commands.table, colordiff, _diff_effects)
-            _setupcmd(_ui, 'qseries', commands.table, colorqseries, _patch_effects)
-        except error.UnknownCommand:
-            # Otherwise we wrap mq.cmdtable
-            _setupcmd(_ui, 'qdiff', mq.cmdtable, colordiff, _diff_effects)
-            _setupcmd(_ui, 'qseries', mq.cmdtable, colorqseries, _patch_effects)
+        _setupcmd(ui, 'qdiff', mq.cmdtable, colordiff, _diff_effects)
+        _setupcmd(ui, 'qseries', mq.cmdtable, colorqseries, _patch_effects)
     except KeyError:
         # The mq extension is not enabled
         pass