[PATCH 2 of 2] color: colorize diffs in hg record/qrecord output

Brodie Rao dackze at gmail.com
Fri Aug 7 12:05:16 CDT 2009


# HG changeset patch
# User Brodie Rao <me+hg at dackz.net>
# Date 1249663609 14400
# Node ID ac7d53f6457cd6b469b39c75240d6c4143587c91
# Parent  75717f90c7e90c9e3a061a223d5ca9c776e7a4dd
color: colorize diffs in hg record/qrecord output

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -230,9 +230,14 @@ def uisetup(ui):
 
     def setupmq(mq):
         _setupcmd(ui, 'qdiff', mq.cmdtable, colordiff, _diff_effects)
+        _setupcmd(ui, 'qrecord', mq.cmdtable, colordiff, _diff_effects)
         _setupcmd(ui, 'qseries', mq.cmdtable, colorqseries, _patch_effects)
     extensions.hook('mq', setupmq)
 
+    def setuprecord(record):
+        _setupcmd(ui, 'record', record.cmdtable, colordiff, _diff_effects)
+    extensions.hook('record', setuprecord)
+
 def _setupcmd(ui, cmd, table, func, effectsmap):
     '''patch in command to command table and load effect map'''
     def nocolor(orig, *args, **opts):
diff --git a/tests/test-record-color b/tests/test-record-color
new file mode 100755
--- /dev/null
+++ b/tests/test-record-color
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+echo "[ui]" >> $HGRCPATH
+echo "interactive=true" >> $HGRCPATH
+echo "[extensions]" >> $HGRCPATH
+echo "color=" >> $HGRCPATH
+echo "record=" >> $HGRCPATH
+echo "[diff]" >> $HGRCPATH
+echo "git=True" >> $HGRCPATH
+
+hg init a
+cd a
+
+cat > a <<EOF
+a
+b
+c
+d
+EOF
+chmod 0644 a
+hg ci -Am adda
+
+echo % modify text
+
+cat > a <<EOF
+a
+c
+d
+e
+EOF
+
+hg record --color=always -m moda a<<EOF
+y
+y
+y
+EOF
+
+echo % modify permissions
+
+chmod 0755 a
+hg record --color=always -m perma a <<EOF
+y
+EOF
+echo
diff --git a/tests/test-record-color.out b/tests/test-record-color.out
new file mode 100644
--- /dev/null
+++ b/tests/test-record-color.out
@@ -0,0 +1,18 @@
+adding a
+% modify text
+diff --git a/a b/a
+2 hunks, 2 lines changed
+examine changes to 'a'? [Ynsfdaq?]  @@ -1,4 +1,3 @@
+ a
+-b
+ c
+ d
+record change 1/2 to 'a'? [Ynsfdaq?]  @@ -3,2 +2,3 @@
+ c
+ d
++e
+record change 2/2 to 'a'? [Ynsfdaq?]  % modify permissions
+diff --git a/a b/a
+old mode 100644
+new mode 100755
+examine changes to 'a'? [Ynsfdaq?]  


More information about the Mercurial-devel mailing list