[PATCH 2 of 2 V2] color: omit terminfo/win32 warning if non-interactive (issue4543)

Jordi GutiƩrrez Hermoso jordigh at octave.org
Tue Mar 10 15:38:44 CDT 2015


# HG changeset patch
# User Jordi GutiƩrrez Hermoso <jordigh at octave.org>
# Date 1426018083 14400
#      Tue Mar 10 16:08:03 2015 -0400
# Node ID 8a99e96e3146a1d10958ef5042f726c95ec616c1
# Parent  dd65a862c6a2298408304d4eeb17a835b5e9d0e9
color: omit terminfo/win32 warning if non-interactive (issue4543)

It's pretty annoying to be getting this warning when already the
colour extension has no hope of working. If there isn't a human on the
other end to to see the colours, there probably isn't a human either
who cares about this warning. More likely, some script somewhere is
gonna get confused with the warning output.

Of course, if we still want to see the warning for some reason, we can
always set --config ui.interactive=True.

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -252,8 +252,9 @@ def _modesetup(ui, coloropt):
             realmode = 'ansi'
 
     def warn_fail_mode():
-        # only warn if color.mode was explicitly set
-        if mode == realmode:
+        # only warn if color.mode was explicitly set and we're in
+        # an interactive terminal
+        if mode == realmode and ui.interactive():
             ui.warn(_('warning: failed to set color mode to %s\n') % mode)
 
     if realmode == 'win32':


More information about the Mercurial-devel mailing list