# HG changeset patch # User Mathias De Maré # Date 1420749022 -3600 # Node ID a857755144dc9f9bb4f0f1d177f80dfcebe08a1b # Parent 427b8728536f2f6ced9aa227786e90f610cf335b color: add support for colorizing git subrepo diffs diff -r 427b8728536f -r a857755144dc hgext/color.py --- a/hgext/color.py Thu Jan 08 23:33:56 2015 -0500 +++ b/hgext/color.py Thu Jan 08 21:30:22 2015 +0100 @@ -144,7 +144,8 @@ import os -from mercurial import cmdutil, commands, dispatch, extensions, ui as uimod, util +from mercurial import cmdutil, commands, dispatch, extensions, subrepo, util +from mercurial import ui as uimod from mercurial import templater, error from mercurial.i18n import _ @@ -488,7 +489,14 @@ extstyles() configstyles(ui_) return orig(ui_, opts, cmd, cmdfunc) + def colorgit(orig, gitsub, commands, env=None, stream=False, cwd=None): + if gitsub.ui._colormode and len(commands) and commands[0] == "diff": + # insert the argument in the front, + # the end of git diff arguments is used for paths + commands.insert(1, '--color') + return orig(gitsub, commands, env, stream, cwd) extensions.wrapfunction(dispatch, '_runcommand', colorcmd) + extensions.wrapfunction(subrepo.gitsubrepo, '_gitnodir', colorgit) templater.funcs['label'] = templatelabel def extsetup(ui):