# HG changeset patch # User Pierre-Yves David # Date 1482370010 -3600 # Node ID ddc80d1777a63db18c7dbc35831601541f30daf6 # Parent 0d2a58a04080a5deb5d95f37c717ad598f444dc6 color: move 'valideffect' function into the core module diff -r 0d2a58a04080 -r ddc80d1777a6 hgext/color.py --- a/hgext/color.py Thu Dec 22 02:23:23 2016 +0100 +++ b/hgext/color.py Thu Dec 22 02:26:50 2016 +0100 @@ -332,16 +332,6 @@ stop = _effect_str('none') return ''.join([start, text, stop]) -def valideffect(effect): - 'Determine if the effect is valid or not.' - good = False - if not color._terminfo_params and effect in color._effects: - good = True - elif (effect in color._terminfo_params - or effect[:-11] in color._terminfo_params): - good = True - return good - def configstyles(ui): for status, cfgeffects in ui.configitems('color'): if '.' not in status or status.startswith(('color.', 'terminfo.')): @@ -350,7 +340,7 @@ if cfgeffects: good = [] for e in cfgeffects: - if valideffect(e): + if color.valideffect(e): good.append(e) else: ui.warn(_("ignoring unknown color/effect %r " @@ -412,7 +402,7 @@ s = color._styles.get(l, '') if s: effects.append(s) - elif valideffect(l): + elif color.valideffect(l): effects.append(l) effects = ' '.join(effects) if effects: diff -r 0d2a58a04080 -r ddc80d1777a6 mercurial/color.py --- a/mercurial/color.py Thu Dec 22 02:23:23 2016 +0100 +++ b/mercurial/color.py Thu Dec 22 02:26:50 2016 +0100 @@ -113,3 +113,13 @@ def loadcolortable(ui, extname, colortable): _styles.update(colortable) + +def valideffect(effect): + 'Determine if the effect is valid or not.' + good = False + if not _terminfo_params and effect in _effects: + good = True + elif (effect in _terminfo_params + or effect[:-11] in _terminfo_params): + good = True + return good