hgext/record.py
changeset 10825 781689b9b6bb
parent 10694 d7732d2df54a
child 10890 301633755dec
--- a/hgext/record.py	Fri Apr 02 15:22:14 2010 -0500
+++ b/hgext/record.py	Fri Apr 02 15:22:15 2010 -0500
@@ -520,7 +520,18 @@
                 os.rmdir(backupdir)
             except OSError:
                 pass
-    return cmdutil.commit(ui, repo, recordfunc, pats, opts)
+
+    # wrap ui.write so diff output can be labeled/colorized
+    def wrapwrite(orig, *args, **kw):
+        label = kw.pop('label', '')
+        for chunk, l in patch.difflabel(lambda: args):
+            orig(chunk, label=label + l)
+    oldwrite = ui.write
+    extensions.wrapfunction(ui, 'write', wrapwrite)
+    try:
+        return cmdutil.commit(ui, repo, recordfunc, pats, opts)
+    finally:
+        ui.write = oldwrite
 
 cmdtable = {
     "record":