Bug 1395267 - [tryselect] Make default try selector used when running |mach try| without subcommands configurable, r=armenzg
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Wed, 30 Aug 2017 14:45:46 -0400
changeset 377831 00dfb5209483ff4e79c261c6179ea29433dbfc1c
parent 377830 7158e7a52d15f413687979643bb1d424ae1563dd
child 377832 a7af20fffd8104203b671f40f8618e91a6da0c93
push id32416
push userarchaeopteryx@coole-files.de
push dateThu, 31 Aug 2017 12:35:23 +0000
treeherdermozilla-central@c9079d347aaa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarmenzg
bugs1395267
milestone57.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 1395267 - [tryselect] Make default try selector used when running |mach try| without subcommands configurable, r=armenzg To use this, create a ~/.mozbuild/machrc file and add: [try] default = fuzzy Now, running |mach try| without a subcommand will default to the fuzzy selector. The syntax selector can still be run with |mach try syntax|. MozReview-Commit-ID: Ai6f8cW3Swq
tools/tryselect/mach_commands.py
--- a/tools/tryselect/mach_commands.py
+++ b/tools/tryselect/mach_commands.py
@@ -6,16 +6,17 @@ from __future__ import absolute_import, 
 
 import argparse
 import os
 import sys
 
 from mach.decorators import (
     CommandProvider,
     Command,
+    SettingsProvider,
     SubCommand,
 )
 
 from mozbuild.base import BuildEnvironmentNotFoundException, MachCommandBase
 
 CONFIG_ENVIRONMENT_NOT_FOUND = '''
 No config environment detected. This means we are unable to properly
 detect test files in the specified paths or tags. Please run:
@@ -39,16 +40,29 @@ def fuzzy_parser():
 
 def generic_parser():
     from tryselect.cli import BaseTryParser
     parser = BaseTryParser()
     parser.add_argument('argv', nargs=argparse.REMAINDER)
     return parser
 
 
+@SettingsProvider
+class TryConfig(object):
+
+    @classmethod
+    def config_settings(cls):
+        from mach.registrar import Registrar
+
+        desc = "The default selector to use when running `mach try` without a subcommand."
+        choices = Registrar.command_handlers['try'].subcommand_handlers.keys()
+
+        return [('try.default', 'string', desc, 'syntax', {'choices': choices})]
+
+
 @CommandProvider
 class TrySelect(MachCommandBase):
 
     @Command('try',
              category='ci',
              description='Push selected tasks to the try server',
              parser=generic_parser)
     def try_default(self, argv, **kwargs):
@@ -65,17 +79,17 @@ class TrySelect(MachCommandBase):
         """
         from tryselect import preset
         if kwargs['list_presets']:
             preset.list_presets()
             return
 
         # We do special handling of presets here so that `./mach try --preset foo`
         # works no matter what subcommand 'foo' was saved with.
-        sub = 'syntax'
+        sub = self._mach_context.settings['try']['default']
         if kwargs['preset']:
             _, section = preset.load(kwargs['preset'])
             sub = 'syntax' if section == 'try' else section
 
         return self._mach_context.commands.dispatch(
             'try', subcommand=sub, context=self._mach_context, argv=argv, **kwargs)
 
     @SubCommand('try',