comparison hgext/color.py @ 24249:5058e6962fcc

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.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Tue, 10 Mar 2015 13:40:14 -0400
parents 4e02418b4236
children c14b1d349af3
comparison
equal deleted inserted replaced
24248:913347bcd59c 24249:5058e6962fcc
252 realmode = 'ansi' 252 realmode = 'ansi'
253 253
254 if realmode == 'win32': 254 if realmode == 'win32':
255 _terminfo_params = {} 255 _terminfo_params = {}
256 if not w32effects: 256 if not w32effects:
257 if mode == 'win32': 257 if mode == 'win32' and ui.interactive():
258 # only warn if color.mode is explicitly set to win32 258 # only warn if color.mode is explicitly set to win32
259 ui.warn(_('warning: failed to set color mode to %s\n') % mode) 259 ui.warn(_('warning: failed to set color mode to %s\n') % mode)
260 return None 260 return None
261 _effects.update(w32effects) 261 _effects.update(w32effects)
262 elif realmode == 'ansi': 262 elif realmode == 'ansi':
263 _terminfo_params = {} 263 _terminfo_params = {}
264 elif realmode == 'terminfo': 264 elif realmode == 'terminfo':
265 _terminfosetup(ui, mode) 265 _terminfosetup(ui, mode)
266 if not _terminfo_params: 266 if not _terminfo_params:
267 if mode == 'terminfo': 267 if mode == 'terminfo' and ui.interactive():
268 ## FIXME Shouldn't we return None in this case too? 268 ## FIXME Shouldn't we return None in this case too?
269 # only warn if color.mode is explicitly set to win32 269 # only warn if color.mode is explicitly set to win32
270 ui.warn(_('warning: failed to set color mode to %s\n') % mode) 270 ui.warn(_('warning: failed to set color mode to %s\n') % mode)
271 realmode = 'ansi' 271 realmode = 'ansi'
272 else: 272 else: