Bug 1400439 - Issue warning when isn't used r?gps draft
authorWes Kocher <wkocher@mozilla.com>
Mon, 18 Sep 2017 13:03:37 -0700
changeset 11674 86eff570c2775334ca3980332abe271e677b74d4
parent 11656 d3d395a1a8f954a0c45aefd1a3196e2212a3d0bd
push id1789
push userbmo:wkocher@mozilla.com
push dateMon, 18 Sep 2017 20:18:59 +0000
reviewersgps
bugs1400439
Bug 1400439 - Issue warning when isn't used r?gps MozReview-Commit-ID: 6lDioLp0GaP
hghooks/mozhghooks/try_warning.py
hghooks/tests/test-try-warning.t
--- a/hghooks/mozhghooks/try_warning.py
+++ b/hghooks/mozhghooks/try_warning.py
@@ -11,16 +11,22 @@ For more information, see https://wiki.m
 TRY_JOBS_MISSING = """
 Your try syntax would not trigger any jobs. Either specify a build
 with '-p' or an arbitrary job with '-j'. If you intended to push
 without triggering any jobs, omit the try syntax completely.
 
 For more information, see https://wiki.mozilla.org/Try.
 """
 
+TRY_CONFIG_MISSING = """
+Your try push was not performed via `mach try`. In the future,
+all try pushes will be required to go through `mach try`. Please
+file usability bugs with mach try in {{INSERT COMPONENT HERE}}.
+"""
+
 
 def print_banner(ui, level, message):
     width = max(len(l) for l in message.splitlines())
     banner = [
         ' {} '.format(level.upper()).center(width, '*'),
         message.strip(),
         '*' * width,
     ]
@@ -30,14 +36,16 @@ def print_banner(ui, level, message):
 def hook(ui, repo, source=None, **kwargs):
     if source in ('pull', 'strip'):
         return 0
 
     tip = repo.changectx('tip')
     comment = tip.description()
     config_found = 'try_task_config.json' in tip.manifest()
     syntax_found = 'try:' in comment
+    if not config_found:
+        print_banner(ui, 'warning', TRY_CONFIG_MISSING)
     if not config_found and not syntax_found:
         print_banner(ui, 'warning', TRY_SYNTAX_MISSING)
     elif syntax_found and "-p none" in comment and "-j" not in comment:
         print_banner(ui, 'error', TRY_JOBS_MISSING)
         return 1
     return 0
--- a/hghooks/tests/test-try-warning.t
+++ b/hghooks/tests/test-try-warning.t
@@ -15,16 +15,23 @@ Pushing a changeset without using try sy
   $ hg push ../server
   pushing to ../server
   searching for changes
   adding changesets
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
   
+  *************************** WARNING ****************************
+  Your try push was not performed via `mach try`. In the future,
+  all try pushes will be required to go through `mach try`. Please
+  file usability bugs with mach try in {{INSERT COMPONENT HERE}}.
+  ****************************************************************
+  
+  
   **************************** WARNING ****************************
   Your push does not specify any jobs to run on try. You can still
   schedule jobs by selecting the drop down at the top right of your
   push in treeherder and choosing 'Add new Jobs'.
   
   For more information, see https://wiki.mozilla.org/Try.
   *****************************************************************
   
@@ -36,32 +43,58 @@ Pushing a changeset with '-p none' shoul
   $ hg push ../server
   pushing to ../server
   searching for changes
   adding changesets
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
   
+  *************************** WARNING ****************************
+  Your try push was not performed via `mach try`. In the future,
+  all try pushes will be required to go through `mach try`. Please
+  file usability bugs with mach try in {{INSERT COMPONENT HERE}}.
+  ****************************************************************
+  
+  
   ***************************** ERROR ******************************
   Your try syntax would not trigger any jobs. Either specify a build
   with '-p' or an arbitrary job with '-j'. If you intended to push
   without triggering any jobs, omit the try syntax completely.
   
   For more information, see https://wiki.mozilla.org/Try.
   ******************************************************************
   
   transaction abort!
   rollback completed
   abort: pretxnchangegroup.try_mandatory hook failed
   [255]
- 
+
 Pushing a changeset with try syntax on the tip should be allowed
 
   $ hg commit --amend -m 'try: -b do -p all'
   saved backup bundle to $TESTTMP/client/.hg/strip-backup/0eb01296232e-7764c983-amend-backup.hg (glob)
   $ hg push ../server
   pushing to ../server
   searching for changes
   adding changesets
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
+  
+  *************************** WARNING ****************************
+  Your try push was not performed via `mach try`. In the future,
+  all try pushes will be required to go through `mach try`. Please
+  file usability bugs with mach try in {{INSERT COMPONENT HERE}}.
+  ****************************************************************
+  
+Pushing a changeset with try_task_config.json should have no warnings
+
+  $ touch try_task_config.json
+  $ hg commit -A -m 'Bug 123 - Add foo'
+  adding try_task_config.json
+  $ hg push ../server
+  pushing to ../server
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files