[PATCH 2 of 2 stable] color: set _colormode to None when mode is unset (issue3895)

Siddharth Agarwal sid0 at fb.com
Fri Apr 19 18:58:52 CDT 2013


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1366415830 25200
#      Fri Apr 19 16:57:10 2013 -0700
# Branch stable
# Node ID a8b636b0dc16463b9845911f7c310ce6ebb6c402
# Parent  f1a1080137afc080daae6f0cbfa255e1409a7ebb
color: set _colormode to None when mode is unset (issue3895)

Previously, colorui assumed that it would only be called when mode wasn't
None. 7ae12ce87594 changed that, so now colorui needs to care about whether it
should colorize output.

diff -r f1a1080137af -r a8b636b0dc16 hgext/color.py
--- a/hgext/color.py	Fri Apr 19 16:57:20 2013 -0700
+++ b/hgext/color.py	Fri Apr 19 16:57:10 2013 -0700
@@ -398,8 +398,8 @@ def uisetup(ui):
         ui.__class__ = colorui
     def colorcmd(orig, ui_, opts, cmd, cmdfunc):
         mode = _modesetup(ui_, opts)
+        colorui._colormode = mode
         if mode:
-            colorui._colormode = mode
             extstyles()
             configstyles(ui_)
         return orig(ui_, opts, cmd, cmdfunc)
diff -r f1a1080137af -r a8b636b0dc16 tests/test-status-color.t
--- a/tests/test-status-color.t	Fri Apr 19 16:57:20 2013 -0700
+++ b/tests/test-status-color.t	Fri Apr 19 16:57:10 2013 -0700
@@ -109,6 +109,16 @@ hg status . in repo root:
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m../1/in_b_1\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4min_b_2\x1b[0m (esc)
   \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4m../in_b\x1b[0m (esc)
+
+Make sure --color=never works
+  $ hg status --color=never
+  ? a/1/in_a_1
+  ? a/in_a
+  ? b/1/in_b_1
+  ? b/2/in_b_2
+  ? b/in_b
+  ? in_root
+
   $ cd ..
 
   $ hg init repo2


More information about the Mercurial-devel mailing list