[PATCH 1 of 2] color: set the ui class in reposetup, before a repo is created

Simon Heimberg simohe at besonet.ch
Thu Apr 18 17:48:09 CDT 2013


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1366322004 -7200
# Node ID a3985f97aadad4c43b53377586a8f47274b4c2b3
# Parent  63a783d1ac852d60e60669b2f8551a9b26de2947
color: set the ui class in reposetup, before a repo is created

Previously only the class of repo.ui was set. The class was set in the wrapper
of dispatch._runcommand. But this is called after the repo is created. Only
the class of repo.ui is set because repo.baseui already exists and is not
accessible.
We now set the class in uisetup because this is called before repo creation.
This is also the place suggested in the wiki for modifying classes.

diff -r 63a783d1ac85 -r a3985f97aada hgext/color.py
--- a/hgext/color.py	Don Apr 18 12:55:58 2013 -0700
+++ b/hgext/color.py	Don Apr 18 23:53:24 2013 +0200
@@ -381,13 +381,13 @@
 def uisetup(ui):
     if ui.plain():
         return
+    if not issubclass(ui.__class__, colorui):
+        colorui.__bases__ = (ui.__class__,)
+        ui.__class__ = colorui
     def colorcmd(orig, ui_, opts, cmd, cmdfunc):
         mode = _modesetup(ui_, opts)
         if mode:
             colorui._colormode = mode
-            if not issubclass(ui_.__class__, colorui):
-                colorui.__bases__ = (ui_.__class__,)
-                ui_.__class__ = colorui
             extstyles()
             configstyles(ui_)
         return orig(ui_, opts, cmd, cmdfunc)


More information about the Mercurial-devel mailing list