changeset 12036:31f02288bbc4

mq: extend support for the --mq argument to extension commands This allows commands like `purge' to accept the --mq option.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 13 Aug 2010 16:05:08 +0200
parents ff1044230bca
children aaf9968bd8b7
files hgext/mq.py tests/test-mq.t
diffstat 2 files changed, 26 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Sun Aug 22 13:17:34 2010 +0200
+++ b/hgext/mq.py	Fri Aug 13 16:05:08 2010 +0200
@@ -2928,13 +2928,21 @@
     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'))]
 
--- a/tests/test-mq.t	Sun Aug 22 13:17:34 2010 +0200
+++ b/tests/test-mq.t	Fri Aug 13 16:05:08 2010 +0200
@@ -170,6 +170,10 @@
   A
   B
 
+add an untracked file
+
+  $ echo >> .hg/patches/flaf
+
 status --mq with color (issue2096)
 
   $ hg status --mq --config extensions.color= --color=always
@@ -177,9 +181,15 @@
   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