hgext/color.py
changeset 14095 877390020477
parent 13998 14c7526fed89
child 14103 a36e8c99d51c
--- a/hgext/color.py	Sun May 01 03:51:04 2011 -0500
+++ b/hgext/color.py	Sat Apr 30 11:18:43 2011 -0500
@@ -100,7 +100,7 @@
 
 '''
 
-import os
+import os, sys
 
 from mercurial import commands, dispatch, extensions, ui as uimod, util
 from mercurial.i18n import _
@@ -307,11 +307,14 @@
             # looks line a cmd.exe console, use win32 API or nothing
             mode = w32effects and 'win32' or 'none'
         else:
-            _terminfosetup(ui)
-            if not _terminfo_params:
-                mode = 'ansi'
+            if getattr(sys.stdout, 'isatty', None) and sys.stdout.isatty():
+                _terminfo_params = False
             else:
-                mode = 'terminfo'
+                _terminfosetup(ui)
+                if not _terminfo_params:
+                    mode = 'ansi'
+                else:
+                    mode = 'terminfo'
     if mode == 'win32':
         if w32effects is None:
             # only warn if color.mode is explicitly set to win32