color: bring back colors with pager
authorYuya Nishihara <yuya@tcha.org>
Tue, 18 May 2010 18:55:14 +0900
changeset 11207 1d714c1546b5
parent 11205 d26f662bfbf5
child 11208 2313dc4d9817
color: bring back colors with pager It's introduced by 3c368a1c962d, but missing in merge changeset at a890cc501501.
hgext/color.py
--- a/hgext/color.py	Thu May 20 15:58:16 2010 -0500
+++ b/hgext/color.py	Tue May 18 18:55:14 2010 +0900
@@ -198,10 +198,14 @@
         _effects.update(w32effects)
     elif mode != 'ansi':
         return
+
+    # check isatty() before anything else changes it (like pager)
+    isatty = sys.__stdout__.isatty()
+
     def colorcmd(orig, ui_, opts, cmd, cmdfunc):
         if (opts['color'] == 'always' or
             (opts['color'] == 'auto' and (os.environ.get('TERM') != 'dumb'
-                                          and sys.__stdout__.isatty()))):
+                                          and isatty))):
             global _buffers
             _buffers = ui_._buffers
             extensions.wrapfunction(ui_, 'popbuffer', popbuffer)