Patchwork [STABLE] color: pass on key error for win32

login
register
mail settings
Submitter Sean Farley
Date Aug. 1, 2014, 6:09 p.m.
Message ID <d85e690bd86678be5b43.1406916552@laptop.local>
Download mbox | patch
Permalink /patch/5219/
State Accepted
Headers show

Comments

Sean Farley - Aug. 1, 2014, 6:09 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1406916546 18000
#      Fri Aug 01 13:09:06 2014 -0500
# Branch stable
# Node ID d85e690bd86678be5b43ede85d9b7521190ae7e6
# Parent  27205c8335b06d8a2718b85c71adfaa3287cec35
color: pass on key error for win32

This is a quick fix for some consoles on windows (consoles that are not mingw
based) so that the debugcolor command doesn't throw a KeyError when effects
aren't supported (e.g. italic).
Matt Mackall - Aug. 1, 2014, 6:10 p.m.
On Fri, 2014-08-01 at 13:09 -0500, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1406916546 18000
> #      Fri Aug 01 13:09:06 2014 -0500
> # Branch stable
> # Node ID d85e690bd86678be5b43ede85d9b7521190ae7e6
> # Parent  27205c8335b06d8a2718b85c71adfaa3287cec35
> color: pass on key error for win32

Queued for stable, thanks.

Patch

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -560,12 +560,16 @@  else:
 
         # determine console attributes based on labels
         for l in label.split():
             style = _styles.get(l, '')
             for effect in style.split():
-                attr = mapcolor(w32effects[effect], attr)
-
+                try:
+                    attr = mapcolor(w32effects[effect], attr)
+                except KeyError:
+                    # w32effects could not have certain attributes so we skip
+                    # them if not found
+                    pass
         # hack to ensure regexp finds data
         if not text.startswith('\033['):
             text = '\033[m' + text
 
         # Look for ANSI-like codes embedded in text