Mercurial > hg-stable
changeset 14095:877390020477
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.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sat, 30 Apr 2011 11:18:43 -0500 |
parents | d10c6835497e |
children | dea93484cf9f |
files | hgext/color.py |
diffstat | 1 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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