[PATCH] color: verify stdout is a tty before using curses

Christian Ebert blacktrash at gmx.org
Sun May 1 05:10:21 CDT 2011


* Augie Fackler on Sunday, May 01, 2011 at 03:33:31 -0500
> # 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

import sys

> --- 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)():

why not sys.stdout.isatty()

As I wrote in my other mail, this disables color in conjunction
with hgext.pager, therefore I think a switch to ansi mode would
be better.

Without this patch, when I enable pager and color (and do not set
mode=ansi explicitly) I see:

^Ochangeset:   14088:e83ced8b6464^O

Did not have time to file an issue.

c
-- 
theatre - books - texts - movies
Black Trash Productions at home: http://www.blacktrash.org
Black Trash Productions on Facebook:
http://www.facebook.com/blacktrashproductions


More information about the Mercurial-devel mailing list