hgext/color.py
changeset 23780 a857755144dc
parent 23173 122f5c3f3308
child 23925 e563e0cfe08c
--- 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):