##// END OF EJS Templates
color: move triggering of the initialisation logic in core...
Pierre-Yves David -
r31105:45be7590 default
parent child Browse files
Show More
@@ -175,9 +175,6 b' from mercurial import ('
175 cmdutil,
175 cmdutil,
176 color,
176 color,
177 commands,
177 commands,
178 dispatch,
179 extensions,
180 ui as uimod,
181 )
178 )
182
179
183 cmdtable = {}
180 cmdtable = {}
@@ -188,15 +185,6 b' command = cmdutil.command(cmdtable)'
188 # leave the attribute unspecified.
185 # leave the attribute unspecified.
189 testedwith = 'ships-with-hg-core'
186 testedwith = 'ships-with-hg-core'
190
187
191 def uisetup(ui):
192 def colorcmd(orig, ui_, opts, cmd, cmdfunc):
193 mode = color._modesetup(ui_, opts['color'])
194 uimod.ui._colormode = mode
195 if mode and mode != 'debug':
196 color.configstyles(ui_)
197 return orig(ui_, opts, cmd, cmdfunc)
198 extensions.wrapfunction(dispatch, '_runcommand', colorcmd)
199
200 def extsetup(ui):
188 def extsetup(ui):
201 # change default color config
189 # change default color config
202 for idx, entry in enumerate(commands.globalopts):
190 for idx, entry in enumerate(commands.globalopts):
@@ -161,6 +161,17 b' def _terminfosetup(ui, mode):'
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
@@ -764,6 +764,10 b' def _dispatch(req):'
764 for ui_ in uis:
764 for ui_ in uis:
765 ui_.insecureconnections = True
765 ui_.insecureconnections = True
766
766
767 # setup color handling
768 for ui_ in uis:
769 color.setup(ui_, options['color'])
770
767 if options['version']:
771 if options['version']:
768 return commands.version_(ui)
772 return commands.version_(ui)
769 if options['help']:
773 if options['help']:
@@ -295,6 +295,7 b' test unknown color'
295
295
296 $ hg --config color.status.modified=periwinkle status --color=always
296 $ hg --config color.status.modified=periwinkle status --color=always
297 ignoring unknown color/effect 'periwinkle' (configured in color.status.modified)
297 ignoring unknown color/effect 'periwinkle' (configured in color.status.modified)
298 ignoring unknown color/effect 'periwinkle' (configured in color.status.modified)
298 M modified
299 M modified
299 \x1b[0;32;1mA \x1b[0m\x1b[0;32;1madded\x1b[0m (esc)
300 \x1b[0;32;1mA \x1b[0m\x1b[0;32;1madded\x1b[0m (esc)
300 \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mcopied\x1b[0m (esc)
301 \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mcopied\x1b[0m (esc)
General Comments 0
You need to be logged in to leave comments. Login now