color: wrap qrecord
authorMartin Geisler <mg@lazybytes.net>
Thu, 05 Nov 2009 01:11:28 +0100
changeset 9711 d29bd00bbc50
parent 9710 1765599f4899
child 9712 18b134ef294c
color: wrap qrecord The qrecord command is registered in uisetup phase, so we do our wrapping in extsetup phase.
hgext/color.py
tests/test-diff-color
tests/test-diff-color.out
--- a/hgext/color.py	Thu Nov 05 01:10:43 2009 +0100
+++ b/hgext/color.py	Thu Nov 05 01:11:28 2009 +0100
@@ -235,7 +235,7 @@
                  'changed': ['white'],
                  'trailingwhitespace': ['bold', 'red_background']}
 
-def uisetup(ui):
+def extsetup(ui):
     '''Initialize the extension.'''
     _setupcmd(ui, 'diff', commands.table, colordiff, _diff_effects)
     _setupcmd(ui, 'incoming', commands.table, None, _diff_effects)
@@ -249,15 +249,17 @@
         _setupcmd(ui, 'qdiff', mq.cmdtable, colordiff, _diff_effects)
         _setupcmd(ui, 'qseries', mq.cmdtable, colorqseries, _patch_effects)
     except KeyError:
-        # The mq extension is not enabled
-        pass
+        mq = None
 
     try:
         rec = extensions.find('record')
         _setupcmd(ui, 'record', rec.cmdtable, colordiff, _diff_effects)
     except KeyError:
-        # The record extension is not enabled
-        pass
+        rec = None
+
+    if mq and rec:
+        _setupcmd(ui, 'qrecord', rec.cmdtable, colordiff, _diff_effects)
+
 
 def _setupcmd(ui, cmd, table, func, effectsmap):
     '''patch in command to command table and load effect map'''
--- a/tests/test-diff-color	Thu Nov 05 01:10:43 2009 +0100
+++ b/tests/test-diff-color	Thu Nov 05 01:11:28 2009 +0100
@@ -51,3 +51,14 @@
 y
 EOF
 echo
+
+echo "[extensions]" >> $HGRCPATH
+echo "mq=" >> $HGRCPATH
+
+hg rollback
+echo % qrecord
+hg qrecord --color=always -m moda patch <<EOF
+y
+y
+EOF
+echo
--- a/tests/test-diff-color.out	Thu Nov 05 01:10:43 2009 +0100
+++ b/tests/test-diff-color.out	Thu Nov 05 01:11:28 2009 +0100
@@ -41,3 +41,19 @@
  a
  c
 record this change to 'a'? [Ynsfdaq?] 
+rolling back last transaction
+% qrecord
+diff --git a/a b/a
+old mode 100644
+new mode 100755
+1 hunks, 2 lines changed
+examine changes to 'a'? [Ynsfdaq?] @@ -2,7 +2,7 @@
+ c
+ a
+ a
+-b
++dd
+ a
+ a
+ c
+record this change to 'a'? [Ynsfdaq?]