Bug 1255467 - Ability for a mach command to dispatch to another's subcommand, r=gps
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Thu, 10 Mar 2016 11:45:39 -0500
changeset 288288 2f5f092a64add23c4bb911179a21352046848406
parent 288287 844d73172246061eab0a612454b4be5aefbcb0df
child 288289 28bca8e29596cfa1c24b864925cb5cb5e20e35ab
push id30079
push userryanvm@gmail.com
push dateSat, 12 Mar 2016 20:24:19 +0000
treeherdermozilla-central@d1d47ba19ce9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1255467
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1255467 - Ability for a mach command to dispatch to another's subcommand, r=gps MozReview-Commit-ID: CN8kJU0NrL0
python/mach/mach/registrar.py
--- a/python/mach/mach/registrar.py
+++ b/python/mach/mach/registrar.py
@@ -94,32 +94,33 @@ class MachRegistrar(object):
 
         if context:
             postrun = getattr(context, 'post_dispatch_handler', None)
             if postrun:
                 postrun(context, handler, args=kwargs)
 
         return result
 
-    def dispatch(self, name, context=None, argv=None, **kwargs):
+    def dispatch(self, name, context=None, argv=None, subcommand=None, **kwargs):
         """Dispatch/run a command.
 
         Commands can use this to call other commands.
         """
-        # TODO handler.subcommand_handlers are ignored
         handler = self.command_handlers[name]
 
+        if subcommand:
+            handler = handler.subcommand_handlers[subcommand]
+
         if handler.parser:
             parser = handler.parser
 
             # save and restore existing defaults so **kwargs don't persist across
             # subsequent invocations of Registrar.dispatch()
             old_defaults = parser._defaults.copy()
             parser.set_defaults(**kwargs)
             kwargs, _ = parser.parse_known_args(argv or [])
             kwargs = vars(kwargs)
             parser._defaults = old_defaults
 
         return self._run_command_handler(handler, context=context, **kwargs)
 
 
-
 Registrar = MachRegistrar()