[PATCH] mq: extend support for the --mq argumemt to extension commands

Dan Villiom Podlaski Christiansen danchr at gmail.com
Fri Aug 13 10:39:05 CDT 2010


# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1281708308 -7200
# Node ID fac5533ecd58c6547b24557a19522a0664432f87
# Parent  22287abb27fdb5240c8874e061a8b2ce65c16089
mq: extend support for the --mq argumemt to extension commands

This allows commands like `purge' to accept the --mq option.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -2875,13 +2875,21 @@ def uisetup(ui):
     entry = extensions.wrapcommand(commands.table, 'init', mqinit)
     entry[1].extend(mqopt)
 
-    norepo = commands.norepo.split(" ")
-    for cmd in commands.table.keys():
-        cmd = cmdutil.parsealiases(cmd)[0]
-        if cmd in norepo:
-            continue
-        entry = extensions.wrapcommand(commands.table, cmd, mqcommand)
-        entry[1].extend(mqopt)
+    nowrap = set(commands.norepo.split(" ") + ['qrecord'])
+
+    def dotable(cmdtable):
+        for cmd in cmdtable.keys():
+            cmd = cmdutil.parsealiases(cmd)[0]
+            if cmd in nowrap:
+                continue
+            entry = extensions.wrapcommand(cmdtable, cmd, mqcommand)
+            entry[1].extend(mqopt)
+
+    dotable(commands.table)
+
+    for extname, extmodule in extensions.extensions():
+        if extmodule.__file__ != __file__:
+            dotable(getattr(extmodule, 'cmdtable', {}))
 
 seriesopts = [('s', 'summary', None, _('print first line of patch header'))]
 
diff --git a/tests/test-mq b/tests/test-mq
--- a/tests/test-mq
+++ b/tests/test-mq
@@ -81,8 +81,14 @@ cat .hg/patches/.hgignore
 echo '  series:'
 cat .hg/patches/series
 
+echo >> .hg/patches/flaf
+
 echo '% status --mq with color (issue2096)'
 hg status --mq --config extensions.color= --color=always
+
+echo '% purge --mq --verbose'
+hg purge --mq --verbose --config extensions.purge=
+
 cd ..
 
 echo '% init --mq without repo'
diff --git a/tests/test-mq.out b/tests/test-mq.out
--- a/tests/test-mq.out
+++ b/tests/test-mq.out
@@ -98,6 +98,9 @@ B
 A A
 A B
 A series
+? flaf
+% purge --mq --verbose
+Removing file flaf
 % init --mq without repo
 abort: There is no Mercurial repository here (.hg not found)
 % init --mq with repo path


More information about the Mercurial-devel mailing list