[PATCH] color: verify stdout is a tty before using curses
Augie Fackler
durin42 at gmail.com
Sat Apr 30 11:54:14 CDT 2011
On Apr 30, 2011, at 6:48 PM, Brodie Rao wrote:
>
> On Apr 30, 2011, at 6:18 PM, Augie Fackler wrote:
>
>> # HG changeset patch
>> # User Augie Fackler <durin42 at gmail.com>
>> # Date 1304180323 18000
>> # Node ID e316d00e4ad54d48364145fe4d8d548ad2f0a3f4
>> # Parent 58e58406ed190ce59c78de13e82da1f6bc47f06c
>> color: verify stdout is a tty before using curses
>>
>> Without this change, curses complains when invoked in certain contexts
>> (such as emacs integration.)
>
> Can you give some instructions on how to reproduce this?
Execute 'hg diff' using emacs's (call-process) inside the (hg-view-output) function from mercurial.el is the way I've observed it.
>
>> 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
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
>
More information about the Mercurial-devel
mailing list