Patchwork [2,of,6] color: make a test for curse availability explicite

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 21, 2017, 10:17 p.m.
Message ID <75a71d27817d72d9516b.1487715478@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/18699/
State Accepted
Headers show

Comments

Pierre-Yves David - Feb. 21, 2017, 10:17 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1482383860 -3600
#      Thu Dec 22 06:17:40 2016 +0100
# Node ID 75a71d27817d72d9516be85134306a8e4b1c5f96
# Parent  60a489f0531abbafc7f53a3dd4bad50f13b38015
# EXP-Topic color
color: make a test for curse availability explicite

We won't use terminfo when curse failed to load. Before this change, we were
doing an indirect test, relying on the fact some variable ('_terminfo_params')
would be empty if curses failed to load. We update the code to be more explicit
and directly checks if we managed to load the curse module.

Patch

diff -r 60a489f0531a -r 75a71d27817d hgext/color.py
--- a/hgext/color.py	Thu Dec 22 03:11:19 2016 +0100
+++ b/hgext/color.py	Thu Dec 22 06:17:40 2016 +0100
@@ -196,7 +196,7 @@  def _terminfosetup(ui, mode):
     '''Initialize terminfo data and the terminal if we're in terminfo mode.'''
 
     # If we failed to load curses, we go ahead and return.
-    if not color._terminfo_params:
+    if curses is None:
         return
     # Otherwise, see what the config file says.
     if mode not in ('auto', 'terminfo'):