[PATCH 05 of 13 V2] color: move the 'colorlabel' call to the core 'ui' class
Durham Goode
durham at fb.com
Fri Feb 24 17:52:16 EST 2017
Minor grammar nit. Series through here looks good to me though.
On 2/24/17 2:09 PM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1487875532 -3600
> # Thu Feb 23 19:45:32 2017 +0100
> # Node ID fd0b7fed70ddeaf0568b02d5e0f9d982a68f1cb4
> # Parent 13f7594f6a7e5cfd7092bcb197039c3c38e2e32f
> # EXP-Topic color
> 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 13f7594f6a7e -r fd0b7fed70dd 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 @@ class colorui(uimod.ui):
> 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 13f7594f6a7e -r fd0b7fed70dd 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 .i18n import _
> from .node import hex
>
> from . import (
> + color,
> config,
> encoding,
> error,
> @@ -1361,13 +1362,15 @@ class ui(object):
> 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 added the necessary control
"this will add"
> + character to apply such color. In addition 'debug' color mode adds
"characters"
> + markup showing which label affect a piece of text.
"affects"
>
> 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):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=nuarHzhP1wi1T9iURRCj1A&m=q_BFVVaJNLRFikc92GufadXG8FV38H3S8DC4IAnY6uo&s=z5fTcjwSHCczooZH8pv2J95NC-runwaQKx3wP1QJik4&e=
>
More information about the Mercurial-devel
mailing list