color: set _colormode to None when mode is unset (issue3895) stable
authorSiddharth Agarwal <sid0@fb.com>
Fri, 19 Apr 2013 16:57:10 -0700
branchstable
changeset 19073 d78d0256198e
parent 19072 b7b50a54bec9
child 19074 a1922b9a2cad
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.
hgext/color.py
tests/test-status-color.t
--- 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 @@
         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)
--- 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 @@
   \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