Patchwork D1532: color: respect HGPLAINEXCEPT=color to allow colors while scripting (issue5749)

login
register
mail settings
Submitter phabricator
Date Dec. 1, 2017, 2:01 p.m.
Message ID <fb2a5af46a04e81e08dec7b00bf7de96@localhost.localdomain>
Download mbox | patch
Permalink /patch/25859/
State Not Applicable
Headers show

Comments

phabricator - Dec. 1, 2017, 2:01 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd4805a5e7e70: color: respect HGPLAINEXCEPT=color to allow colors while scripting (issue5749) (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1532?vs=4018&id=4046

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

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

CHANGE DETAILS




To: durin42, #hg-reviewers, yuja
Cc: xalep, mercurial-devel

Patch

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
@@ -29,6 +29,22 @@ 
   [status.unknown|? ][status.unknown|b/2/in_b_2]
   [status.unknown|? ][status.unknown|b/in_b]
   [status.unknown|? ][status.unknown|in_root]
+HGPLAIN disables color
+  $ HGPLAIN=1 hg status --color=debug
+  ? a/1/in_a_1
+  ? a/in_a
+  ? b/1/in_b_1
+  ? b/2/in_b_2
+  ? b/in_b
+  ? in_root
+HGPLAINEXCEPT=color does not disable color
+  $ HGPLAINEXCEPT=color hg status --color=debug
+  [status.unknown|? ][status.unknown|a/1/in_a_1]
+  [status.unknown|? ][status.unknown|a/in_a]
+  [status.unknown|? ][status.unknown|b/1/in_b_1]
+  [status.unknown|? ][status.unknown|b/2/in_b_2]
+  [status.unknown|? ][status.unknown|b/in_b]
+  [status.unknown|? ][status.unknown|in_root]
 
 hg status with template
   $ hg status -T "{label('red', path)}\n" --color=debug
diff --git a/mercurial/help/environment.txt b/mercurial/help/environment.txt
--- a/mercurial/help/environment.txt
+++ b/mercurial/help/environment.txt
@@ -65,6 +65,8 @@ 
 
     ``alias``
         Don't remove aliases.
+    ``color``
+        Don't disable colored output.
     ``i18n``
         Preserve internationalization.
     ``revsetalias``
diff --git a/mercurial/color.py b/mercurial/color.py
--- a/mercurial/color.py
+++ b/mercurial/color.py
@@ -181,7 +181,7 @@ 
         configstyles(ui)
 
 def _modesetup(ui):
-    if ui.plain():
+    if ui.plain('color'):
         return None
     config = ui.config('ui', 'color')
     if config == 'debug':