diff --git a/mercurial/color.py b/mercurial/color.py --- a/mercurial/color.py +++ b/mercurial/color.py @@ -211,7 +211,7 @@ def _modesetup(ui): - if ui.plain(b'color'): + if ui.plain(b'color') or encoding.environ.get(b"NO_COLOR") is not None: return None config = ui.config(b'ui', b'color') if config == b'debug': 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 @@ -46,6 +46,15 @@ [status.unknown|? ][status.unknown|b/in_b] (glob) [status.unknown|? ][status.unknown|in_root] +NO_COLOR disables color no matter what + $ NO_COLOR= HGPLAINEXCEPT=color hg status --color=debug + ? a/1/in_a_1 (glob) + ? a/in_a (glob) + ? b/1/in_b_1 (glob) + ? b/2/in_b_2 (glob) + ? b/in_b (glob) + ? in_root + hg status with template $ hg status -T "{label('red', path)}\n" --color=debug [red|a/1/in_a_1]