Bug 1512188 - Move enforcement of non-symbolic revisions to vcs_checkout(); r=tomprince
☠☠ backed out by f3fead0d1dc7 ☠ ☠
authorGregory Szorc <gps@mozilla.com>
Tue, 11 Dec 2018 19:50:52 +0000
changeset 450124 d9585e5d7a3a3224aaa58a03fab24c3b5ab870f2
parent 450123 b4f3dc9b09560bb158dd8ea666a508454100a8cc
child 450125 d0eb311b3c8f1251462257207cfa9f2a0408238f
push id35190
push userccoroiu@mozilla.com
push dateWed, 12 Dec 2018 05:10:47 +0000
treeherdermozilla-central@5bcbe5232a26 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstomprince
bugs1512188
milestone66.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 1512188 - Move enforcement of non-symbolic revisions to vcs_checkout(); r=tomprince Having this consistently enforced in the checkout function seems better than looking at environment variables. Also, I think the old logic was wrong, as it only ran if we weren't doing a checkout! Although there is a strong possibility that I introduced this bug via refactoring in this series. Differential Revision: https://phabricator.services.mozilla.com/D13820
taskcluster/scripts/run-task
--- a/taskcluster/scripts/run-task
+++ b/taskcluster/scripts/run-task
@@ -383,30 +383,36 @@ def configure_volume_posix(volume, user,
                               b'to %d:%d\n' % (volume.encode('utf-8'),
                                                user.pw_uid,
                                                group.gr_gid))
         set_dir_permissions(volume, user.pw_uid, group.gr_gid)
 
 
 def vcs_checkout(source_repo, dest, store_path,
                  base_repo=None, revision=None, branch=None,
-                 fetch_hgfingerprint=False, sparse_profile=None):
+                 fetch_hgfingerprint=False, sparse_profile=None,
+                 prevent_symbolic_revisions=True):
     # Specify method to checkout a revision. This defaults to revisions as
     # SHA-1 strings, but also supports symbolic revisions like `tip` via the
     # branch flag.
     if revision:
         revision_flag = '--revision'
         revision_value = revision
     elif branch:
         revision_flag = '--branch'
         revision_value = branch
     else:
         print('revision is not specified for checkout')
         sys.exit(1)
 
+    if prevent_symbolic_revisions and not revision:
+        print('symbolic revisions (%s) to specific checkout revision are not'
+              'allowed; specify a full revision hash instead' % branch)
+        sys.exit(1)
+
     if IS_POSIX:
         hg_bin = 'hg'
     elif IS_WINDOWS:
         # This is where OCC installs it in the AMIs.
         hg_bin = r'C:\Program Files\Mercurial\hg.exe'
         if not os.path.exists(hg_bin):
             print('could not find Mercurial executable: %s' % hg_bin)
             sys.exit(1)
@@ -731,42 +737,32 @@ def main(args):
             firefox_checkout['checkout'],
             firefox_checkout['store-path'],
             fetch_hgfingerprint=args.fetch_hgfingerprint,
             base_repo=firefox_checkout['base-repo'],
             revision=firefox_checkout['revision'],
             branch=firefox_checkout['branch'],
             sparse_profile=firefox_checkout['sparse-profile'])
 
-    elif not os.environ.get('GECKO_HEAD_REV') and \
-            os.environ.get('GECKO_HEAD_REF'):
-        print('task should be defined in terms of non-symbolic revision')
-        return 1
-
     # Checkout the repository, setting the COMM_HEAD_REV to the current
     # revision hash. Revision hashes have priority over symbolic revisions. We
     # disallow running tasks with symbolic revisions unless they have been
     # resolved by a checkout.
     comm_checkout = collect_vcs_options(args, 'comm')
     if comm_checkout:
         os.environ['COMM_HEAD_REV'] = vcs_checkout(
             comm_checkout['head-repo'],
             comm_checkout['checkout'],
             comm_checkout['store-path'],
             fetch_hgfingerprint=args.fetch_hgfingerprint,
             base_repo=comm_checkout['base-repo'],
             revision=comm_checkout['revision'],
             branch=comm_checkout['branch'],
             sparse_profile=comm_checkout['sparse-profile'])
 
-    elif not os.environ.get('COMM_HEAD_REV') and \
-            os.environ.get('COMM_HEAD_REF'):
-        print('task should be defined in terms of non-symbolic revision')
-        return 1
-
     try:
         if 'GECKO_PATH' in os.environ:
             os.environ['GECKO_PATH'] = os.path.abspath(os.environ['GECKO_PATH'])
 
         if 'MOZ_FETCHES' in os.environ:
             fetch_artifacts()
 
         return run_and_prefix_output(b'task', task_args)