[PATCH stable] color: tweak behavior of ui.color config knob

Yuya Nishihara yuya at tcha.org
Mon May 1 22:44:36 EDT 2017


On Mon, 01 May 2017 21:13:12 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie at google.com>
> # Date 1493678508 14400
> #      Mon May 01 18:41:48 2017 -0400
> # Branch stable
> # Node ID 9524b0b5eedb877c4dc2d1afefa423ea9149e874
> # Parent  7c76f3923b6a4fd6a35a9b498be15b9c549955eb
> color: tweak behavior of ui.color config knob
> 
> marmoute sent some other patches today that tried to bring
> pager.enabled into conformity with ui.color, and while reviewing those
> patches I tripped on some unfortunate usability warts on the behavior
> of the (new in 4.2) ui.color config knob. Specifically, ui.color=yes
> actually means "always show color", not "use color automatically when
> it appears sensible". This feels problematic because if an
> administrator has disabled color, and a user wants to turn it on, the
> obvious setting (color=on) is wrong (because it breaks their output
> when redirected to a file.) This patch changes ui.color to only move
> the default value of --color from "never" to "auto", which matches the
> relationship of pager.enabed and --pager.

I'm 0 on this since ui.color sounds okay not being a simple boolean.

> --- a/mercurial/color.py
> +++ b/mercurial/color.py
> @@ -185,10 +185,17 @@ def setup(ui):
>  def _modesetup(ui):
>      if ui.plain():
>          return None
> +    # ui.color only controls the default of the --color flag: true
> +    # means to automatically use color when sensible, and false means
> +    # to never use color.
> +    wantcolor = ui.configbool('ui', 'color', _enabledbydefault)

ui.color=auto becomes invalid so we'll have to update the doc.


More information about the Mercurial-devel mailing list