color: add support for churn --diffstat
authorAlexander Solovyov <piranha@piranha.org.ua>
Mon, 30 Nov 2009 23:10:21 +0200
changeset 10004 af04a3dea4cd
parent 10003 a1217735dffb
child 10005 68964567e406
color: add support for churn --diffstat
hgext/color.py
--- a/hgext/color.py	Thu Dec 03 22:54:33 2009 +0100
+++ b/hgext/color.py	Mon Nov 30 23:10:21 2009 +0200
@@ -213,6 +213,16 @@
     finally:
         ui.write = oldwrite
 
+def colorchurn(orig, ui, repo, *pats, **opts):
+    '''run the churn command with colored output'''
+    if not opts.get('diffstat'):
+        return orig(ui, repo, *pats, **opts)
+    oldwrite = extensions.wrapfunction(ui, 'write', colordiffstat)
+    try:
+        orig(ui, repo, *pats, **opts)
+    finally:
+        ui.write = oldwrite
+
 _diff_prefixes = [('diff', 'diffline'),
                   ('copy', 'extended'),
                   ('rename', 'extended'),
@@ -259,7 +269,11 @@
 
     if mq and rec:
         _setupcmd(ui, 'qrecord', rec.cmdtable, colordiff, _diff_effects)
-
+    try:
+        churn = extensions.find('churn')
+        _setupcmd(ui, 'churn', churn.cmdtable, colorchurn, _diff_effects)
+    except KeyError:
+        churn = None
 
 def _setupcmd(ui, cmd, table, func, effectsmap):
     '''patch in command to command table and load effect map'''