diff --git a/mercurial/color.py b/mercurial/color.py --- a/mercurial/color.py +++ b/mercurial/color.py @@ -193,7 +193,14 @@ def _modesetup(ui): return 'debug' auto = (config == 'auto') - always = not auto and util.parsebool(config) + 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': + always = True + else: + auto = True + if not always and not auto: return None diff --git a/mercurial/help/color.txt b/mercurial/help/color.txt --- a/mercurial/help/color.txt +++ b/mercurial/help/color.txt @@ -5,15 +5,15 @@ in red, while the status command shows m other commands have analogous colors. It is possible to customize these colors. -To enable color (default) use:: +To enable color (default) whenever possible use:: [ui] - color = auto + color = yes To disable color use:: [ui] - color = never + color = no See :hg:`help config.ui.color` for details. diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt --- a/mercurial/help/config.txt +++ b/mercurial/help/config.txt @@ -1884,9 +1884,9 @@ User interface controls. By default, the first bundle advertised by the server is used. ``color`` - When to colorize output. Possible value are Boolean, "always", "auto", - "never", or "debug". (default: "auto"). "auto" will use color - whenever it seems possible. See :hg:`help color` for details. + 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. ``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 @@ -3,6 +3,7 @@ Setup $ cat <> $HGRCPATH > [ui] > color = always + > formatted = always > [color] > mode = ansi > EOF @@ -49,6 +50,38 @@ default context a c +(check that 'ui.color=yes' match '--color=auto') + + $ hg diff --nodates --config ui.formatted=no + diff -r cf9f4ba66af2 a + --- a/a + +++ b/a + @@ -2,7 +2,7 @@ + c + a + a + -b + +dd + a + a + c + +(check that 'ui.color=no' disable color) + + $ hg diff --nodates --config ui.formatted=yes --config ui.color=no + diff -r cf9f4ba66af2 a + --- a/a + +++ b/a + @@ -2,7 +2,7 @@ + c + a + a + -b + +dd + 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 @@ -161,6 +161,7 @@ even though stdout is no longer a tty. $ cat >> $HGRCPATH < [ui] > color = yes + > formatted = yes > [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 @@ -142,6 +142,7 @@ even though stdout is no longer a tty. $ cat >> $HGRCPATH < [ui] > color = yes + > formatted = yes > [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,6 +1,7 @@ $ cat <> $HGRCPATH > [ui] > color = always + > formatted = yes > [color] > mode = ansi > EOF