hgext/color.py
branchstable
changeset 11182 3c368a1c962d
parent 10477 44b4a2a31623
child 11186 a890cc501501
--- a/hgext/color.py	Thu May 13 11:30:50 2010 -0500
+++ b/hgext/color.py	Mon May 03 14:00:34 2010 -0500
@@ -333,11 +333,14 @@
 
 def _setupcmd(ui, cmd, table, func, effectsmap):
     '''patch in command to command table and load effect map'''
+    # check isatty() before anything else changes it (like pager)
+    isatty = sys.__stdout__.isatty()
+
     def nocolor(orig, *args, **opts):
 
         if (opts['no_color'] or opts['color'] == 'never' or
             (opts['color'] == 'auto' and (os.environ.get('TERM') == 'dumb'
-                                          or not sys.__stdout__.isatty()))):
+                                          or not isatty))):
             del opts['no_color']
             del opts['color']
             return orig(*args, **opts)