Mercurial > hg
changeset 32103:9a98023ac8db stable
color: special case 'always' in 'ui.color'
This lift the confusing case, where 'ui.color=always' would actually not always
use color.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 02 May 2017 20:19:09 +0200 |
parents | 9a85ea1daf49 |
children | f06d23af6cdf |
files | mercurial/color.py mercurial/help/config.txt tests/test-diff-color.t tests/test-pager-legacy.t tests/test-pager.t tests/test-status-color.t |
diffstat | 6 files changed, 24 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/color.py Tue May 02 20:01:54 2017 +0200 +++ b/mercurial/color.py Tue May 02 20:19:09 2017 +0200 @@ -195,8 +195,9 @@ 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
--- a/mercurial/help/config.txt Tue May 02 20:01:54 2017 +0200 +++ b/mercurial/help/config.txt Tue May 02 20:19:09 2017 +0200 @@ -1885,8 +1885,8 @@ ``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
--- a/tests/test-diff-color.t Tue May 02 20:01:54 2017 +0200 +++ b/tests/test-diff-color.t Tue May 02 20:19:09 2017 +0200 @@ -2,7 +2,7 @@ $ cat <<EOF >> $HGRCPATH > [ui] - > color = always + > color = yes > formatted = always > [color] > mode = ansi @@ -82,6 +82,22 @@ 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
--- a/tests/test-pager-legacy.t Tue May 02 20:01:54 2017 +0200 +++ b/tests/test-pager-legacy.t Tue May 02 20:19:09 2017 +0200 @@ -160,8 +160,7 @@ even though stdout is no longer a tty. $ cat >> $HGRCPATH <<EOF > [ui] - > color = yes - > formatted = yes + > color = always > [color] > mode = ansi > EOF