Mercurial > hg-stable
changeset 14103:a36e8c99d51c
color: use ui.formatted() to test TTYness, not sys.stdout.isatty()
This fixes the color extension not working with pager (broken in
877390020477). The pager extension already sets ui.formatted=True to
allow this use case.
author | Brodie Rao <brodie@bitheap.org> |
---|---|
date | Sun, 01 May 2011 12:14:22 +0200 |
parents | 7f45b1911893 |
children | f45c8db21749 |
files | hgext/color.py |
diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/color.py Sun May 01 11:12:36 2011 +0200 +++ b/hgext/color.py Sun May 01 12:14:22 2011 +0200 @@ -301,13 +301,15 @@ global _terminfo_params if ui.plain(): return + + formatted = (os.environ.get('TERM') != 'dumb' and ui.formatted()) mode = ui.config('color', 'mode', 'auto') if mode == 'auto': if os.name == 'nt' and 'TERM' not in os.environ: # looks line a cmd.exe console, use win32 API or nothing mode = w32effects and 'win32' or 'none' else: - if getattr(sys.stdout, 'isatty', None) and sys.stdout.isatty(): + if not formatted: _terminfo_params = False else: _terminfosetup(ui) @@ -332,8 +334,7 @@ auto = coloropt == 'auto' always = util.parsebool(coloropt) if (always or - (always is None and - (auto and (os.environ.get('TERM') != 'dumb' and ui_.formatted())))): + (always is None and auto and formatted)): colorui._colormode = mode colorui.__bases__ = (ui_.__class__,) ui_.__class__ = colorui