comparison mercurial/debugcommands.py @ 31689:57a22f699179

color: stop mutating the default effects map A future change will make color.setup() callable a second time when the pager is spawned, in order to honor the 'color.pagermode' setting. The problem was that when 'color.mode=auto' was resolved to 'win32' in the first pass, the default ANSI effects were overwritten, making it impossible to honor 'pagermode=ansi'. Also, the two separate maps didn't have the same keys. The symmetric difference is 'dim' and 'italic' (from ANSI), and 'bold_background' (from win32). Thus, the update left entries that didn't belong for the current mode. This bled through `hg debugcolor`, where the unsupported ANSI keys were listed in 'win32' mode. As an added bonus, this now correctly enables color with MSYS `less` for a command like this, where pager is forced on: $ hg log --config color.pagermode=ansi --pager=yes --color=auto Previously, the output was corrupted. The raw output, as seen through the ANSI blind `more.com` was: <-[-1;6mchangeset: 34840:3580d1197af9<-[-1m ... which MSYS `less -FRX` rendered as: 1;6mchangeset: 34840:3580d1197af91m ... (The two '<-' instances were actually an arrow character that TortoiseHg warned couldn't be encoded, and notepad++ translated to a single '?'.) Returning an empty map for 'ui._colormode == None' seems better that defaulting to '_effects' (since some keys are mode dependent), and is better than None, which blows up `hg debugcolor --color=never`.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 25 Mar 2017 13:50:17 -0400
parents 35738db2037a
children 70d163b86316
comparison
equal deleted inserted replaced
31688:c5fe0c7dad94 31689:57a22f699179
358 return _debugdisplaycolor(ui) 358 return _debugdisplaycolor(ui)
359 359
360 def _debugdisplaycolor(ui): 360 def _debugdisplaycolor(ui):
361 ui = ui.copy() 361 ui = ui.copy()
362 ui._styles.clear() 362 ui._styles.clear()
363 for effect in color._effects.keys(): 363 for effect in color._activeeffects(ui).keys():
364 ui._styles[effect] = effect 364 ui._styles[effect] = effect
365 if ui._terminfoparams: 365 if ui._terminfoparams:
366 for k, v in ui.configitems('color'): 366 for k, v in ui.configitems('color'):
367 if k.startswith('color.'): 367 if k.startswith('color.'):
368 ui._styles[k] = k[6:] 368 ui._styles[k] = k[6:]