Mercurial > hg
changeset 30653:b2be4ccaff1d
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
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Fri, 18 Nov 2016 18:18:15 +0100 |
parents | 1ec42bdd7874 |
children | f35397fe0c04 |
files | hgext/color.py mercurial/color.py mercurial/dispatch.py |
diffstat | 3 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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):
--- 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)
--- 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'),