hgext/color.py
changeset 23780 a857755144dc
parent 23173 122f5c3f3308
child 23925 e563e0cfe08c
equal deleted inserted replaced
23779:427b8728536f 23780:a857755144dc
   142 codes).
   142 codes).
   143 '''
   143 '''
   144 
   144 
   145 import os
   145 import os
   146 
   146 
   147 from mercurial import cmdutil, commands, dispatch, extensions, ui as uimod, util
   147 from mercurial import cmdutil, commands, dispatch, extensions, subrepo, util
       
   148 from mercurial import ui as uimod
   148 from mercurial import templater, error
   149 from mercurial import templater, error
   149 from mercurial.i18n import _
   150 from mercurial.i18n import _
   150 
   151 
   151 cmdtable = {}
   152 cmdtable = {}
   152 command = cmdutil.command(cmdtable)
   153 command = cmdutil.command(cmdtable)
   486         colorui._colormode = mode
   487         colorui._colormode = mode
   487         if mode and mode != 'debug':
   488         if mode and mode != 'debug':
   488             extstyles()
   489             extstyles()
   489             configstyles(ui_)
   490             configstyles(ui_)
   490         return orig(ui_, opts, cmd, cmdfunc)
   491         return orig(ui_, opts, cmd, cmdfunc)
       
   492     def colorgit(orig, gitsub, commands, env=None, stream=False, cwd=None):
       
   493         if gitsub.ui._colormode and len(commands) and commands[0] == "diff":
       
   494                 # insert the argument in the front,
       
   495                 # the end of git diff arguments is used for paths
       
   496                 commands.insert(1, '--color')
       
   497         return orig(gitsub, commands, env, stream, cwd)
   491     extensions.wrapfunction(dispatch, '_runcommand', colorcmd)
   498     extensions.wrapfunction(dispatch, '_runcommand', colorcmd)
       
   499     extensions.wrapfunction(subrepo.gitsubrepo, '_gitnodir', colorgit)
   492     templater.funcs['label'] = templatelabel
   500     templater.funcs['label'] = templatelabel
   493 
   501 
   494 def extsetup(ui):
   502 def extsetup(ui):
   495     commands.globalopts.append(
   503     commands.globalopts.append(
   496         ('', 'color', 'auto',
   504         ('', 'color', 'auto',