Bug 1486970: [taskgraph] Make find_hg_revision_pushlog_id more re-usable; r=Callek
authorTom Prince <mozilla@hocat.ca>
Tue, 27 Nov 2018 19:13:23 +0000
changeset 504973 d6229a4bce1ad2b785a8f6da57bdbf49906bc123
parent 504972 ba69286f9c33df034a2a471859acaf9cd12d9380
child 504974 b59f4aa8d4a32212a3cedeb8779c13fda9863569
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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 1486970: [taskgraph] Make find_hg_revision_pushlog_id more re-usable; r=Callek Differential Revision: https://phabricator.services.mozilla.com/D13103
--- a/taskcluster/taskgraph/actions/release_promotion.py
+++ b/taskcluster/taskgraph/actions/release_promotion.py
@@ -7,17 +7,17 @@
 from __future__ import absolute_import, print_function, unicode_literals
 import json
 import os
 from .registry import register_callback_action
 from .util import find_decision_task, find_existing_tasks_from_previous_kinds
-from taskgraph.util.hg import find_hg_revision_pushlog_id
+from taskgraph.util.hg import find_hg_revision_push_info
 from taskgraph.util.taskcluster import get_artifact
 from taskgraph.util.partials import populate_release_history
 from taskgraph.util.partners import (
@@ -287,18 +287,21 @@ def release_promotion_action(parameters,
     # make parameters read-write
     parameters = dict(parameters)
     # Build previous_graph_ids from ``previous_graph_ids``, ``pushlog_id``,
     # or ``revision``.
     previous_graph_ids = input.get('previous_graph_ids')
     if not previous_graph_ids:
         revision = input.get('revision')
-        parameters['pushlog_id'] = parameters['pushlog_id'] or \
-            find_hg_revision_pushlog_id(parameters, graph_config, revision)
+        if not parameters['pushlog_id']:
+            repo_param = '{}head_repository'.format(graph_config['project-repo-param-prefix'])
+            push_info = find_hg_revision_push_info(
+                repository=parameters[repo_param], revision=revision)
+            parameters['pushlog_id'] = push_info['pushid']
         previous_graph_ids = [find_decision_task(parameters, graph_config)]
     # Download parameters from the first decision task
     parameters = get_artifact(previous_graph_ids[0], "public/parameters.yml")
     # Download and combine full task graphs from each of the previous_graph_ids.
     # Sometimes previous relpro action tasks will add tasks, like partials,
     # that didn't exist in the first full_task_graph, so combining them is
     # important. The rightmost graph should take precedence in the case of
--- a/taskcluster/taskgraph/util/hg.py
+++ b/taskcluster/taskgraph/util/hg.py
@@ -7,31 +7,31 @@
 from __future__ import absolute_import
 import requests
 import subprocess
 PUSHLOG_TMPL = '{}/json-pushes?version=2&changeset={}&tipsonly=1&full=1'
-def find_hg_revision_pushlog_id(parameters, graph_config, revision):
+def find_hg_revision_push_info(repository, revision):
     """Given the parameters for this action and a revision, find the
     pushlog_id of the revision."""
-    repo_param = '{}head_repository'.format(graph_config['project-repo-param-prefix'])
-    pushlog_url = PUSHLOG_TMPL.format(parameters[repo_param], revision)
+    pushlog_url = PUSHLOG_TMPL.format(repository, revision)
     r = requests.get(pushlog_url)
-    pushes = r.json()['pushes'].keys()
+    pushes = r.json()['pushes']
     if len(pushes) != 1:
         raise RuntimeError(
             "Unable to find a single pushlog_id for {} revision {}: {}".format(
-                parameters['head_repository'], revision, pushes
+                repository, revision, pushes
-    return pushes[0]
+    pushid = pushes.keys()[0]
+    return {'pushdate': pushes[pushid]['date'], 'pushid': pushid}
 def get_hg_revision_branch(root, revision):
     """Given the parameters for a revision, find the hg_branch (aka
     relbranch) of the revision."""
     return subprocess.check_output(['hg', 'identify', '--branch', '--rev', revision], cwd=root)