# HG changeset patch # User Mathias De Maré # Date 2015-01-08 20:30:22 # Node ID a857755144dc9f9bb4f0f1d177f80dfcebe08a1b # Parent 427b8728536f2f6ced9aa227786e90f610cf335b color: add support for colorizing git subrepo diffs diff --git a/hgext/color.py b/hgext/color.py --- a/hgext/color.py +++ b/hgext/color.py @@ -144,7 +144,8 @@ codes). 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 @@ def uisetup(ui): 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):