comparison mercurial/color.py @ 31105:45be7590301d

color: move triggering of the initialisation logic in core We now run the color initialisation as part of the standard dispatch. This is opening the way for multiple cleanups since we now have access to the multiple 'ui' object and we'll be able to see difference between global and local config. This cleanup will arrive in later changesets. As a side effect, the '--color' flag is now working without the extension. Since we now properly initialize color for each ui idependently, we get a warning message twice.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Tue, 21 Feb 2017 18:20:12 +0100
parents c1997c5d1ae3
children a185b903bda3
comparison
equal deleted inserted replaced
31104:8346b2f09e79 31105:45be7590301d
159 if mode == "terminfo": 159 if mode == "terminfo":
160 ui.warn(_("no terminfo entry for setab/setaf: reverting to " 160 ui.warn(_("no terminfo entry for setab/setaf: reverting to "
161 "ECMA-48 color\n")) 161 "ECMA-48 color\n"))
162 _terminfo_params.clear() 162 _terminfo_params.clear()
163 163
164 def setup(ui, coloropts):
165 """configure color on a ui
166
167 The 'coloropts' argument is the value of the '--color' command line
168 argument. That function both set the colormode for the ui object and read
169 the configuration looking for custom colors and effect definitions."""
170 mode = _modesetup(ui, coloropts)
171 ui.__class__._colormode = mode
172 if mode and mode != 'debug':
173 configstyles(ui)
174
164 def _modesetup(ui, coloropt): 175 def _modesetup(ui, coloropt):
165 if ui.plain(): 176 if ui.plain():
166 return None 177 return None
167 if coloropt == 'debug': 178 if coloropt == 'debug':
168 return 'debug' 179 return 'debug'