author | Andrew Halberstadt <ahalberstadt@mozilla.com> |
Tue, 01 Oct 2019 12:40:28 +0000 | |
changeset 495729 | 4fbb6d14488034abc1bf7675a30dbbc14f6c004a |
parent 495728 | b50c4cdef2ac1ed8949753711f608f19fd12acb3 |
child 495730 | 9ffde0fb448b092c0b931610ee26d26e0ddb30a7 |
push id | 36638 |
push user | shindli@mozilla.com |
push date | Wed, 02 Oct 2019 03:38:52 +0000 |
treeherder | mozilla-central@cb9bbf38fa45 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | nalexander |
bugs | 1584567 |
milestone | 71.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
|
--- a/python/mach/mach/decorators.py +++ b/python/mach/mach/decorators.py @@ -26,19 +26,16 @@ class _MachCommand(object): 'subcommand', 'category', 'description', 'conditions', '_parser', 'arguments', 'argument_group_names', - # When `conditions` are met, rename this command to the following name. - 'conditional_name', - # Describes how dispatch is performed. # The Python class providing the command. This is the class type not # an instance of the class. Mach will instantiate a new instance of # the class if the command is executed. 'cls', # Whether the __init__ method of the class should receive a mach @@ -52,27 +49,25 @@ class _MachCommand(object): 'method', # Dict of string to _MachCommand defining sub-commands for this # command. 'subcommand_handlers', ) def __init__(self, name=None, subcommand=None, category=None, - description=None, conditions=None, parser=None, - conditional_name=None): + description=None, conditions=None, parser=None): self.name = name self.subcommand = subcommand self.category = category self.description = description self.conditions = conditions or [] self._parser = parser self.arguments = [] self.argument_group_names = [] - self.conditional_name = conditional_name self.cls = None self.pass_context = None self.method = None self.subcommand_handlers = {} @property def parser(self):
--- a/python/mach/mach/main.py +++ b/python/mach/mach/main.py @@ -396,18 +396,16 @@ To see more help for a specific command, context = CommandContext(cwd=self.cwd, settings=self.settings, log_manager=self.log_manager, commands=Registrar) if self.populate_context_handler: self.populate_context_handler(context) context = ContextWrapper(context, self.populate_context_handler) - Registrar.register_conditional_names(context) - parser = self.get_argument_parser(context) if not len(argv): # We don't register the usage until here because if it is globally # registered, argparse always prints it. This is not desired when # running with --help. parser.usage = Mach.USAGE parser.print_usage()
--- a/python/mach/mach/registrar.py +++ b/python/mach/mach/registrar.py @@ -45,40 +45,16 @@ class MachRegistrar(object): def register_settings_provider(self, cls): self.settings_providers.add(cls) def register_category(self, name, title, description, priority=50): self.categories[name] = (title, description, priority) self.commands_by_category[name] = set() - def register_conditional_names(self, context): - """For every handler with a conditional name, use that name if - the handler's conditions are met.""" - - # Avoid updating while iterating. - names = list(self.command_handlers.keys()) - - for name in names: - handler = self.command_handlers[name] - if handler.conditional_name: - instance = MachRegistrar._instance(handler, context) - fail_conditions = MachRegistrar._fail_conditions(handler, instance) - - if fail_conditions: - continue - - # We passed our conditions. Unregister the existing name. - del self.command_handlers[name] - self.commands_by_category[handler.category].remove(name) - - # Register with the new name. - handler.name = handler.conditional_name - self.register_command_handler(handler) - @classmethod def _condition_failed_message(cls, name, conditions): msg = ['\n'] for c in conditions: part = [' %s' % c.__name__] if c.__doc__ is not None: part.append(c.__doc__) msg.append(' - '.join(part))