diff hgext/color.py @ 9412:3a78bbc57660

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.
author Martin Geisler <mg@lazybytes.net>
date Sat, 29 Aug 2009 00:30:03 +0200
parents ad73f6986ef5
children 32ec70799172
line wrap: on
line diff
--- 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