# HG changeset patch # User Pierre-Yves David # Date 2017-05-02 18:19:09 # Node ID 9a98023ac8dbac13fb03b5369dfaf83145860268 # Parent 9a85ea1daf49b7785b8448834e3e944a14fb991f color: special case 'always' in 'ui.color' This lift the confusing case, where 'ui.color=always' would actually not always use color. diff --git a/mercurial/color.py b/mercurial/color.py --- a/mercurial/color.py +++ b/mercurial/color.py @@ -195,8 +195,9 @@ def _modesetup(ui): auto = (config == 'auto') always = False if not auto and util.parsebool(config): - # we want the config to behave like a boolean, "on" is actually auto - if ui.configsource('ui', 'color') == '--color': + # We want the config to behave like a boolean, "on" is actually auto, + # but "always" value is treated as a special case to reduce confusion. + if ui.configsource('ui', 'color') == '--color' or config == 'always': always = True else: auto = True diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt --- a/mercurial/help/config.txt +++ b/mercurial/help/config.txt @@ -1885,8 +1885,8 @@ User interface controls. ``color`` When to colorize output. Possible value are Boolean ("yes" or "no"), or - "debug". (default: "yes"). "yes" will use color whenever it seems possible. - See :hg:`help color` for details. + "debug", or "always". (default: "yes"). "yes" will use color whenever it + seems possible. See :hg:`help color` for details. ``commitsubrepos`` Whether to commit modified subrepositories when committing the diff --git a/tests/test-diff-color.t b/tests/test-diff-color.t --- a/tests/test-diff-color.t +++ b/tests/test-diff-color.t @@ -2,7 +2,7 @@ Setup $ cat <> $HGRCPATH > [ui] - > color = always + > color = yes > formatted = always > [color] > mode = ansi @@ -82,6 +82,22 @@ default context a c +(check that 'ui.color=always' force color) + + $ hg diff --nodates --config ui.formatted=no --config ui.color=always + \x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc) + \x1b[0;31;1m--- a/a\x1b[0m (esc) + \x1b[0;32;1m+++ b/a\x1b[0m (esc) + \x1b[0;35m@@ -2,7 +2,7 @@\x1b[0m (esc) + c + a + a + \x1b[0;31m-b\x1b[0m (esc) + \x1b[0;32m+dd\x1b[0m (esc) + a + a + c + --unified=2 $ hg diff --nodates -U 2 diff --git a/tests/test-pager-legacy.t b/tests/test-pager-legacy.t --- a/tests/test-pager-legacy.t +++ b/tests/test-pager-legacy.t @@ -160,8 +160,7 @@ Pager with color enabled allows colors t even though stdout is no longer a tty. $ cat >> $HGRCPATH < [ui] - > color = yes - > formatted = yes + > color = always > [color] > mode = ansi > EOF diff --git a/tests/test-pager.t b/tests/test-pager.t --- a/tests/test-pager.t +++ b/tests/test-pager.t @@ -141,8 +141,7 @@ Pager with color enabled allows colors t even though stdout is no longer a tty. $ cat >> $HGRCPATH < [ui] - > color = yes - > formatted = yes + > color = always > [color] > mode = ansi > EOF diff --git a/tests/test-status-color.t b/tests/test-status-color.t --- a/tests/test-status-color.t +++ b/tests/test-status-color.t @@ -1,7 +1,6 @@ $ cat <> $HGRCPATH > [ui] > color = always - > formatted = yes > [color] > mode = ansi > EOF