Patchwork [2,of,3] color: ignore effects missing from terminfo

login
register
mail settings
Submitter Danek Duvall
Date Oct. 13, 2016, 8:27 p.m.
Message ID <333e875ce30da3760c86.1476390454@smelly>
Download mbox | patch
Permalink /patch/17068/
State Accepted
Headers show

Comments

Danek Duvall - Oct. 13, 2016, 8:27 p.m.
# HG changeset patch
# User Danek Duvall <danek.duvall@oracle.com>
# Date 1476385301 25200
#      Thu Oct 13 12:01:41 2016 -0700
# Node ID 333e875ce30da3760c8655e303d9bea554efe7e4
# Parent  61e74a19770c2ce80c0cedc429915112261e5c1b
color: ignore effects missing from terminfo

If terminfo mode is in effect, and an effect is used which is missing from
the terminfo database, simply silently ignore the request, leaving the
output unaffected rather than causing a crash.

Patch

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -369,7 +369,10 @@  def _effect_str(effect):
     if effect.endswith('_background'):
         bg = True
         effect = effect[:-11]
-    attr, val, termcode = _terminfo_params[effect]
+    try:
+        attr, val, termcode = _terminfo_params[effect]
+    except KeyError:
+        return ''
     if attr:
         if termcode:
             return termcode