changeset 23780:a857755144dc

color: add support for colorizing git subrepo diffs
author Mathias De Maré <mathias.demare@gmail.com>
date Thu, 08 Jan 2015 21:30:22 +0100
parents 427b8728536f
children 49caef455912
files hgext/color.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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):