[PATCH 3 of 5] color: use ui.formatted()

Dan Villiom Podlaski Christiansen danchr at gmail.com
Mon Jun 7 09:23:49 CDT 2010


# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1275917334 -7200
# Node ID b7b18d67f502486919d68a3c5e44aa37b1b49be4
# Parent  ea8faa0a748ac47708180b404fea836bfec918f2
color: use ui.formatted().

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -198,14 +198,10 @@ def uisetup(ui):
         _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 isatty))):
+                                          and ui_.formatted()))):
             global _buffers
             _buffers = ui_._buffers
             extensions.wrapfunction(ui_, 'popbuffer', popbuffer)


More information about the Mercurial-devel mailing list