Bug 1518572 - [mach] Stuff the 'handler' instance into the context when applicable r=firefox-build-system-reviewers,mshal
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Mon, 25 Feb 2019 16:19:05 +0000
changeset 518844 9afd71742756ebb5a6c66b592aef96624c2972f8
parent 518843 69598c5631cecd60154f9595a8a207e1e03c7d06
child 518845 d7a45b84e0636abebded47eef06460871aa50ff9
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfirefox-build-system-reviewers, mshal
bugs1518572
milestone67.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 1518572 - [mach] Stuff the 'handler' instance into the context when applicable r=firefox-build-system-reviewers,mshal For mach commands that have 'pass_context=True', we should implicitly add the handler instance to the context. This will give mach command implementations an easy way to access things like the command/subcommand names, the parser, argv list, etc. Differential Revision: https://phabricator.services.mozilla.com/D20521
python/mach/mach/registrar.py
--- a/python/mach/mach/registrar.py
+++ b/python/mach/mach/registrar.py
@@ -64,16 +64,17 @@ class MachRegistrar(object):
             raise Exception('mach command class requires context.')
 
         if context:
             prerun = getattr(context, 'pre_dispatch_handler', None)
             if prerun:
                 prerun(context, handler, args=kwargs)
 
         if handler.pass_context:
+            context.handler = handler
             instance = cls(context)
         else:
             instance = cls()
 
         if handler.conditions:
             fail_conditions = []
             for c in handler.conditions:
                 if not c(instance):