comparison hgext/color.py @ 21991:aca137619a45 stable

color: pass on key error for win32 (issue4298) 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).
author Sean Farley <sean.michael.farley@gmail.com>
date Fri, 01 Aug 2014 13:09:06 -0500
parents 35eb333d61d5
children fbd67cf34799
comparison
equal deleted inserted replaced
21990:48e32c2c499b 21991:aca137619a45
560 560
561 # determine console attributes based on labels 561 # determine console attributes based on labels
562 for l in label.split(): 562 for l in label.split():
563 style = _styles.get(l, '') 563 style = _styles.get(l, '')
564 for effect in style.split(): 564 for effect in style.split():
565 attr = mapcolor(w32effects[effect], attr) 565 try:
566 566 attr = mapcolor(w32effects[effect], attr)
567 except KeyError:
568 # w32effects could not have certain attributes so we skip
569 # them if not found
570 pass
567 # hack to ensure regexp finds data 571 # hack to ensure regexp finds data
568 if not text.startswith('\033['): 572 if not text.startswith('\033['):
569 text = '\033[m' + text 573 text = '\033[m' + text
570 574
571 # Look for ANSI-like codes embedded in text 575 # Look for ANSI-like codes embedded in text