Mercurial > hg
diff mercurial/ui.py @ 31087:894bdcdc75df
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.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Thu, 23 Feb 2017 19:45:32 +0100 |
parents | c42feb5f3143 |
children | e9f96ccf36a6 |
line wrap: on
line diff
--- 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):