mq: extend support for the --mq argument to extension commands
This allows commands like `purge' to accept the --mq option.
--- 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 @@
[0;32;1mA A[0m
[0;32;1mA B[0m
[0;32;1mA series[0m
+ [0;35;1;4m? flaf[0m
+
+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