Mercurial > hg
comparison hgext/color.py @ 31102:96d561c90ad0
color: move git-subrepo support into the subrepo module
Now that all ui instance carry a '_colormode' attribute, we can access and
comply to it directly in the subrepo code. The actual implementation could
probably be a bit smarter, but we stick close to the current one for the sake
of simplicity.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 21 Feb 2017 17:50:04 +0100 |
parents | 9021a94a7dbf |
children | c1997c5d1ae3 |
comparison
equal
deleted
inserted
replaced
31101:9021a94a7dbf | 31102:96d561c90ad0 |
---|---|
175 cmdutil, | 175 cmdutil, |
176 color, | 176 color, |
177 commands, | 177 commands, |
178 dispatch, | 178 dispatch, |
179 extensions, | 179 extensions, |
180 subrepo, | |
181 ui as uimod, | 180 ui as uimod, |
182 ) | 181 ) |
183 | 182 |
184 cmdtable = {} | 183 cmdtable = {} |
185 command = cmdutil.command(cmdtable) | 184 command = cmdutil.command(cmdtable) |
196 mode = color._modesetup(ui_, opts['color']) | 195 mode = color._modesetup(ui_, opts['color']) |
197 uimod.ui._colormode = mode | 196 uimod.ui._colormode = mode |
198 if mode and mode != 'debug': | 197 if mode and mode != 'debug': |
199 color.configstyles(ui_) | 198 color.configstyles(ui_) |
200 return orig(ui_, opts, cmd, cmdfunc) | 199 return orig(ui_, opts, cmd, cmdfunc) |
201 def colorgit(orig, gitsub, commands, env=None, stream=False, cwd=None): | |
202 if gitsub.ui._colormode and len(commands) and commands[0] == "diff": | |
203 # insert the argument in the front, | |
204 # the end of git diff arguments is used for paths | |
205 commands.insert(1, '--color') | |
206 return orig(gitsub, commands, env, stream, cwd) | |
207 extensions.wrapfunction(dispatch, '_runcommand', colorcmd) | 200 extensions.wrapfunction(dispatch, '_runcommand', colorcmd) |
208 extensions.wrapfunction(subrepo.gitsubrepo, '_gitnodir', colorgit) | |
209 | 201 |
210 def extsetup(ui): | 202 def extsetup(ui): |
211 commands.globalopts.append( | 203 commands.globalopts.append( |
212 ('', 'color', 'auto', | 204 ('', 'color', 'auto', |
213 # i18n: 'always', 'auto', 'never', and 'debug' are keywords | 205 # i18n: 'always', 'auto', 'never', and 'debug' are keywords |