changeset 14768:55db12e54450 stable

color: fix TypeError with auto mode on win32 when colors aren't available (issue2871) This can happen when stdout isn't a terminal (e.g., it's being piped).
author Brodie Rao <brodie@bitheap.org>
date Wed, 29 Jun 2011 13:20:39 -0400
parents aab323df2c44
children 9adce4b38ed1
files hgext/color.py
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/color.py	Tue Jun 28 00:56:33 2011 +0200
+++ b/hgext/color.py	Wed Jun 29 13:20:39 2011 -0400
@@ -174,9 +174,10 @@
             realmode = 'terminfo'
 
     if realmode == 'win32':
-        if not w32effects and mode == 'win32':
-            # only warn if color.mode is explicitly set to win32
-            ui.warn(_('warning: failed to set color mode to %s\n') % mode)
+        if not w32effects:
+            if mode == 'win32':
+                # only warn if color.mode is explicitly set to win32
+                ui.warn(_('warning: failed to set color mode to %s\n') % mode)
             return None
         _effects.update(w32effects)
     elif realmode == 'ansi':