[PATCH 1 of 6] color: move '_colormode' to the core 'ui' class

Gregory Szorc gregory.szorc at gmail.com
Wed Feb 22 12:31:01 EST 2017



> On Feb 22, 2017, at 08:54, Pierre-Yves David <pierre-yves.david at ens-lyon.org> wrote:
> 
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1487589128 -3600
> #      Mon Feb 20 12:12:08 2017 +0100
> # Node ID d32d64e7e9f084bf01cbac178ad2c2e74e130f9d
> # Parent  80f04ba7f4d1f439d726068f02172f9a52b981fe
> # EXP-Topic color
> color: move '_colormode' to the core 'ui' class
> 
> Having all 'ui' objects aware of 'color' allows us to update the core code to
> handle color. The mode will stay 'None' in the default case so that will not
> introduce any changes.
> 
> diff -r 80f04ba7f4d1 -r d32d64e7e9f0 hgext/color.py
> --- a/hgext/color.py    Thu Dec 22 06:18:45 2016 +0100
> +++ b/hgext/color.py    Mon Feb 20 12:12:08 2017 +0100
> @@ -297,7 +297,6 @@ def _modesetup(ui, coloropt):
>     return None
> 
> class colorui(uimod.ui):
> -    _colormode = None
>     def write(self, *args, **opts):
>         if self._colormode is None:
>             return super(colorui, self).write(*args, **opts)
> diff -r 80f04ba7f4d1 -r d32d64e7e9f0 mercurial/ui.py
> --- a/mercurial/ui.py    Thu Dec 22 06:18:45 2016 +0100
> +++ b/mercurial/ui.py    Mon Feb 20 12:12:08 2017 +0100
> @@ -127,6 +127,8 @@ def _catchterm(*args):
>     raise error.SignalInterrupt
> 
> class ui(object):
> +    # color mode: see mercurial/color.py for possible value
> +    _colormode = None
>     def __init__(self, src=None):
>         """Create a fresh new ui object if no src given

Can you take this opportunity to move this assignment into __init__?


More information about the Mercurial-devel mailing list