[PATCH] color: verify stdout is a tty before using curses
Augie Fackler
durin42 at gmail.com
Sun May 1 03:33:31 CDT 2011
# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1304180323 18000
# Node ID 392119dd7bd1e351fb3bd7435bb92c440ab1cedb
# Parent e83ced8b6464ff8f4c6cd9e4b780ba4b5d6208e0
color: verify stdout is a tty before using curses
Without this change, curses complains when invoked in certain contexts
because stdout isn't a tty (such as emacs integration) but we ask it
to check for various bits of information from terminfo.
diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -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', lambda : False)():
+ _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
More information about the Mercurial-devel
mailing list