# HG changeset patch # User Pierre-Yves David # Date 1479489495 -3600 # Node ID b2be4ccaff1d89356cbd9637aa9191e8048012b6 # Parent 1ec42bdd7874476e5b9e6536f7e57a600d6c8ec8 color: load 'colortable' from extension using an 'extraloader' Now that we have the '_style' dictionary in core, we can use the clean and standard 'extraloader' mechanism to load extension's 'colortable'. color.loadcolortable diff -r 1ec42bdd7874 -r b2be4ccaff1d hgext/color.py --- a/hgext/color.py Fri Nov 18 18:09:36 2016 +0100 +++ b/hgext/color.py Fri Nov 18 18:18:15 2016 +0100 @@ -359,10 +359,6 @@ stop = _effect_str('none') return ''.join([start, text, stop]) -def extstyles(): - for name, ext in extensions.extensions(): - color._styles.update(getattr(ext, 'colortable', {})) - def valideffect(effect): 'Determine if the effect is valid or not.' good = False @@ -460,7 +456,6 @@ mode = _modesetup(ui_, opts['color']) colorui._colormode = mode if mode and mode != 'debug': - extstyles() configstyles(ui_) return orig(ui_, opts, cmd, cmdfunc) def colorgit(orig, gitsub, commands, env=None, stream=False, cwd=None): diff -r 1ec42bdd7874 -r b2be4ccaff1d mercurial/color.py --- a/mercurial/color.py Fri Nov 18 18:09:36 2016 +0100 +++ b/mercurial/color.py Fri Nov 18 18:18:15 2016 +0100 @@ -60,3 +60,6 @@ 'status.unknown': 'magenta bold underline', 'tags.normal': 'green', 'tags.local': 'black bold'} + +def loadcolortable(ui, extname, colortable): + _styles.update(colortable) diff -r 1ec42bdd7874 -r b2be4ccaff1d mercurial/dispatch.py --- a/mercurial/dispatch.py Fri Nov 18 18:09:36 2016 +0100 +++ b/mercurial/dispatch.py Fri Nov 18 18:18:15 2016 +0100 @@ -25,6 +25,7 @@ from . import ( cmdutil, + color, commands, debugcommands, demandimport, @@ -635,6 +636,7 @@ # extraobj) arguments extraloaders = [ ('cmdtable', commands, 'loadcmdtable'), + ('colortable', color, 'loadcolortable'), ('filesetpredicate', fileset, 'loadpredicate'), ('revsetpredicate', revset, 'loadpredicate'), ('templatefilter', templatefilters, 'loadfilter'),