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

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date March 10, 2015, 8:38 p.m.
Message ID <8a99e96e3146a1d10958.1426019924@Iris>
Download mbox | patch
Permalink /patch/7978/
State Accepted
Commit 5058e6962fcca9194ca78a5436902513168437e9
Headers show

Comments

Jordi Gutiérrez Hermoso - March 10, 2015, 8:38 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@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.

Patch

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':