mq: defer command wrapping to extsetup (API)
authorMatt Harbison <matt_harbison@yahoo.com>
Fri, 08 Jun 2012 23:27:59 -0400
changeset 17101 6bc275593d07
parent 17100 ee2370d866fc
child 17102 d9a046ae4d8e
mq: defer command wrapping to extsetup (API) mq wraps all commands that are not in commands.norepo, which is now performed in this second phase of the extensions setup process. This goes against the current best practices on the wiki [1] as far as where command wrapping is performed, but follows it regarding where global options are injected. mq needs to be the first layer called when command dispatching in order to consistently retarget to the patch repo, regardless of the load order of the extensions. This means being the last to wrap the command table. Previously, 'hg <extdiff> --mq' would diff the main repo unless mq was enabled after extdiff. [1] http://mercurial.selenic.com/wiki/WritingExtensions
hgext/mq.py
--- a/hgext/mq.py	Wed Jul 04 09:38:07 2012 -0700
+++ b/hgext/mq.py	Fri Jun 08 23:27:59 2012 -0400
@@ -3537,13 +3537,12 @@
     applied = set([repo[r.node].rev() for r in repo.mq.applied])
     return [r for r in subset if r in applied]
 
-def extsetup(ui):
-    revset.symbols['mq'] = revsetmq
-
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = [revsetmq]
 
-def uisetup(ui):
+def extsetup(ui):
+    # Ensure mq wrappers are called first, regardless of extension load order by
+    # NOT wrapping in uisetup() and instead deferring to init stage two here.
     mqopt = [('', 'mq', None, _("operate on patch repository"))]
 
     extensions.wrapcommand(commands.table, 'import', mqimport)
@@ -3568,6 +3567,7 @@
         if extmodule.__file__ != __file__:
             dotable(getattr(extmodule, 'cmdtable', {}))
 
+    revset.symbols['mq'] = revsetmq
 
 colortable = {'qguard.negative': 'red',
               'qguard.positive': 'yellow',