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

login
register
mail settings
Submitter Siddharth Agarwal
Date April 19, 2013, 11:58 p.m.
Message ID <a8b636b0dc16463b9845.1366415932@sid0x220>
Download mbox | patch
Permalink /patch/1462/
State Accepted
Commit d78d0256198e1cddc189536b957bd6bc30b57319
Headers show

Comments

Siddharth Agarwal - April 19, 2013, 11:58 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@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.
Simon Heimberg - April 24, 2013, 10:25 p.m.
I am terrible sorry for having broken this.
Thank you very much for fixing it, especially for having reacted this 
quickly. And for the tests which prevent breaking again.

Greetings,
simohe

On 2013-04-20 01:58, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@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.
>
(snip)
Siddharth Agarwal - April 25, 2013, 12:13 a.m.
On 04/24/2013 03:25 PM, Simon H. wrote:
> I am terrible sorry for having broken this.
> Thank you very much for fixing it, especially for having reacted this 
> quickly. And for the tests which prevent breaking again.

No problem. I break stuff all the time too!

Patch

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