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

Dan Villiom Podlaski Christiansen danchr at gmail.com
Sun Aug 15 17:40:22 CDT 2010


# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1281708308 -7200
# Node ID f8ec22c7dedaf3fae1b767d6681381a391760e5f
# Parent  96061709c86078f9458c7986c63f85faba1bcce5
mq: extend support for the --mq argument 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.t b/tests/test-mq.t
--- a/tests/test-mq.t
+++ b/tests/test-mq.t
@@ -172,6 +172,10 @@ qinit -c shouldn't touch these files if 
   A
   B
 
+add an untracked file
+
+  $ echo >> .hg/patches/flaf
+
 status --mq with color (issue2096)
 
   $ hg status --mq --config extensions.color= --color=always
@@ -179,9 +183,15 @@ status --mq with color (issue2096)
   A A
   A B
   A series
+  ? flaf
+
+try the --mq option on a command provided by an extension
+
+  $ hg purge --mq --verbose --config extensions.purge=
+  Removing file flaf
+
   $ cd ..
 
-
 init --mq without repo
 
   $ mkdir f


More information about the Mercurial-devel mailing list