# HG changeset patch # User Pierre-Yves David # Date 1487875532 -3600 # Node ID 894bdcdc75df1da72ba245d6512759e37da3e673 # Parent e6082078c8539803b924dcec90fe872bbd8ad3b4 color: move the 'colorlabel' call to the core 'ui' class This bring us closer to supporting color in core natively. Core already have a 'label' method that was a no-op. We update its to call the new 'colorlabel' function. Behavior is unchanged when colormode = None. diff -r e6082078c853 -r 894bdcdc75df hgext/color.py --- a/hgext/color.py Thu Feb 23 19:10:24 2017 +0100 +++ b/hgext/color.py Thu Feb 23 19:45:32 2017 +0100 @@ -328,11 +328,6 @@ return super(colorui, self).write_err( *[self.label(a, label) for a in args], **opts) - def label(self, msg, label): - if self._colormode is None: - return super(colorui, self).label(msg, label) - return color.colorlabel(self, msg, label) - def uisetup(ui): if ui.plain(): return diff -r e6082078c853 -r 894bdcdc75df mercurial/ui.py --- a/mercurial/ui.py Thu Feb 23 19:10:24 2017 +0100 +++ b/mercurial/ui.py Thu Feb 23 19:45:32 2017 +0100 @@ -26,6 +26,7 @@ from .node import hex from . import ( + color, config, encoding, error, @@ -1364,13 +1365,15 @@ def label(self, msg, label): '''style msg based on supplied label - Like ui.write(), this just returns msg unchanged, but extensions - and GUI tools can override it to allow styling output without - writing it. + If some color mode is enabled, this will add the necessary control + characters to apply such color. In addition, 'debug' color mode adds + markup showing which label affects a piece of text. ui.write(s, 'label') is equivalent to ui.write(ui.label(s, 'label')). ''' + if self._colormode is not None: + return color.colorlabel(self, msg, label) return msg def develwarn(self, msg, stacklevel=1, config=None):