Bug 1512188 - Collect environment variables into VCS options; r=tomprince,dustin
authorGregory Szorc <gps@mozilla.com>
Mon, 31 Dec 2018 18:52:32 +0000
changeset 509320 0af08435172d476b85c57f2c64eb652497594c0e
parent 509319 315bb83dabea111b7620b3c8ddb0b50d47c17052
child 509321 504a204f8619f84e4deeefe9bcba48bd1bb0cb3c
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstomprince, dustin
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 - Collect environment variables into VCS options; r=tomprince,dustin This makes behavior consistent across all VCS checkouts. I'm still not a fan of using environment variables here. But at least this gets us 1 step closer to being able to plug alternate logic in without having to update use of environment variables outside a single function. Differential Revision: https://phabricator.services.mozilla.com/D13816
taskcluster/scripts/run-task
--- a/taskcluster/scripts/run-task
+++ b/taskcluster/scripts/run-task
@@ -511,23 +511,34 @@ def add_vcs_arguments(parser, project, n
     parser.add_argument('--%s-sparse-profile' % project,
                         help='Path to sparse profile for %s checkout' % name)
 
 
 def collect_vcs_options(args, project):
     checkout = getattr(args, '%s_checkout' % project)
     sparse_profile = getattr(args, '%s_sparse_profile' % project)
 
+    env_prefix = project.upper()
+
+    base_repo = os.environ.get('%s_BASE_REPOSITORY' % env_prefix)
+    head_repo = os.environ.get('%s_HEAD_REPOSITORY' % env_prefix)
+    revision = os.environ.get('%s_HEAD_REV' % env_prefix)
+    branch = os.environ.get('%s_HEAD_REF' % env_prefix)
+
     if checkout:
         checkout = os.path.expanduser(checkout)
 
     return {
         'project': project,
         'checkout': checkout,
         'sparse-profile': sparse_profile,
+        'base-repo': base_repo,
+        'head-repo': head_repo,
+        'revision': revision,
+        'branch': branch,
     }
 
 
 def main(args):
     print_line(b'setup', b'run-task started in %s\n' % os.getcwd().encode('utf-8'))
     running_as_root = IS_POSIX and os.getuid() == 0
 
     # Arguments up to '--' are ours. After are for the main task
@@ -705,58 +716,52 @@ def main(args):
 
     # Checkout the repository, setting the GECKO_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.
     gecko_options = collect_vcs_options(args, 'gecko')
 
     if gecko_options['checkout']:
-        base_repo = os.environ.get('GECKO_BASE_REPOSITORY')
+        base_repo = gecko_checkout['base-repo']
         # Some callers set the base repository to mozilla-central for historical
         # reasons. Switch to mozilla-unified because robustcheckout works best
         # with it.
         if base_repo == 'https://hg.mozilla.org/mozilla-central':
             base_repo = 'https://hg.mozilla.org/mozilla-unified'
 
         os.environ['GECKO_HEAD_REV'] = vcs_checkout(
-            os.environ['GECKO_HEAD_REPOSITORY'],
+            gecko_options['head-repo'],
             gecko_options['checkout'],
             os.environ['HG_STORE_PATH'],
             fetch_hgfingerprint=args.fetch_hgfingerprint,
             base_repo=base_repo,
-            revision=os.environ.get('GECKO_HEAD_REV'),
-            branch=os.environ.get('GECKO_HEAD_REF'),
+            revision=gecko_options['revision'],
+            branch=gecko_options['branch'],
             sparse_profile=gecko_options['sparse-profile'])
-
-    elif not os.environ.get('GECKO_HEAD_REV') and \
-            os.environ.get('GECKO_HEAD_REF'):
+    elif gecko_options['branch'] and not gecko_options['revision']:
         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_options = collect_vcs_options(args, 'comm')
     if comm_options['checkout']:
-        base_repo = os.environ.get('COMM_BASE_REPOSITORY')
-
         os.environ['COMM_HEAD_REV'] = vcs_checkout(
-            os.environ['COMM_HEAD_REPOSITORY'],
+            comm_options['head-repo'],
             comm_options['checkout'],
             os.environ['HG_STORE_PATH'],
             fetch_hgfingerprint=args.fetch_hgfingerprint,
-            base_repo=base_repo,
-            revision=os.environ.get('COMM_HEAD_REV'),
-            branch=os.environ.get('COMM_HEAD_REF'),
+            base_repo=comm_options['base-repo'],
+            revision=comm_options['revision'],
+            branch=comm_options['branch'],
             sparse_profile=comm_options['sparse-profile'])
-
-    elif not os.environ.get('COMM_HEAD_REV') and \
-            os.environ.get('COMM_HEAD_REF'):
+    elif comm_options['branch'] and not comm_options['revision']:
         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: