Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The https://no-color.org initiative is a good idea, it's easy to support. It
  even explicitly lists Mercurial as one of the programs that don't support it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12587

AFFECTED FILES
  mercurial/color.py
  tests/test-status-color.t

CHANGE DETAILS

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]
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':



To: Alphare, #hg-reviewers
Cc: mercurial-patches, spectral, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to