[PATCH 2 of 2 STABLE] color: special case 'always' in 'ui.color'
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Tue May 2 14:32:53 EDT 2017
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1493749149 -7200
# Tue May 02 20:19:09 2017 +0200
# Branch stable
# Node ID 292a081fcddae9b20c6466d3d3e09a9ce2f55429
# Parent d862ebc515bfc09f2d9e6c32a509092b6434fbd1
# EXP-Topic color
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
# hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 292a081fcdda
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
@@ -1882,8 +1882,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 <<EOF >> $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 <<EOF
> [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 <<EOF
> [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 <<EOF >> $HGRCPATH
> [ui]
> color = always
- > formatted = yes
> [color]
> mode = ansi
> EOF
More information about the Mercurial-devel
mailing list