Bug 1400425 - Add a `mach try empty` command to push to try with no prompts r?ahal draft
authorWes Kocher <wkocher@mozilla.com>
Fri, 15 Sep 2017 18:23:43 -0700
changeset 665883 deb20ef09003307db9a2344df603e5faa0e944ee
parent 665648 6be5c7d30d2def62a762ac187252eba626b23a92
child 731922 32004f47aec226d22777dc947eba8d909a717425
push id80214
push userbmo:wkocher@mozilla.com
push dateSat, 16 Sep 2017 06:44:58 +0000
reviewersahal
bugs1400425
milestone57.0a1
Bug 1400425 - Add a `mach try empty` command to push to try with no prompts r?ahal MozReview-Commit-ID: 6PbT23WHzZM
tools/tryselect/mach_commands.py
tools/tryselect/selectors/empty.py
tools/tryselect/vcs.py
--- a/tools/tryselect/mach_commands.py
+++ b/tools/tryselect/mach_commands.py
@@ -138,16 +138,31 @@ class TrySelect(MachCommandBase):
         For example:
 
           ^start 'exact | !ignore fuzzy end$
         """
         from tryselect.selectors.fuzzy import run_fuzzy_try
         return run_fuzzy_try(**kwargs)
 
     @SubCommand('try',
+                'empty',
+                description='Push to try without scheduling any tasks.')
+    def try_empty(self):
+        """Push to try, running no builds or tests
+
+        This selector does not prompt you to run anything, it just pushes
+        your patches to try, running no builds or tests by default. After
+        the push finishes, you can manually add desired jobs to your push
+        via Treeherder's Add New Jobs feature, located in the per-push
+        menu.
+        """
+        from tryselect.selectors.empty import run_empty_try
+        return run_empty_try()
+
+    @SubCommand('try',
                 'syntax',
                 description='Select tasks on try using try syntax',
                 parser=syntax_parser)
     def try_syntax(self, **kwargs):
         """Push the current tree to try, with the specified syntax.
 
         Build options, platforms and regression tests may be selected
         using the usual try options (-b, -p and -u respectively). In
new file mode 100644
--- /dev/null
+++ b/tools/tryselect/selectors/empty.py
@@ -0,0 +1,19 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+import platform
+import subprocess
+
+from ..vcs import VCSHelper
+
+
+def run_empty_try(update=False, query=None, templates=None, full=False, parameters=None,
+                  save=False, preset=None, list_presets=False, push=True, **kwargs):
+    vcs = VCSHelper.create()
+
+    query = " with query: {}".format(query) if query else ""
+    msg = "Pushed via 'mach try empty'{}".format(query)
+    return vcs.push_to_try("Pused via `mach try empty`", [])
--- a/tools/tryselect/vcs.py
+++ b/tools/tryselect/vcs.py
@@ -95,17 +95,18 @@ class VCSHelper(object):
         if self.has_uncommitted_changes:
             print(UNCOMMITTED_CHANGES)
             sys.exit(1)
 
     def push_to_try(self, msg, labels=None, templates=None, push=True):
         self.check_working_directory(push)
 
         config = None
-        if labels:
+
+        if labels or labels == []:
             config = self.write_task_config(labels, templates)
 
         try:
             if not push:
                 print("Calculated try selector:")
                 if config:
                     with open(config) as fh:
                         print(fh.read())