Bug 1210536 - Use long hg revision in ship-it. r=Callek
authorRail Aliiev <rail@mozilla.com>
Tue, 22 Mar 2016 13:30:33 -0400
changeset 6631 0121cecfae81a2da3bc6ad124f90267a40f12489
parent 6630 37db3e86c835c55f81092fba2de5979059fbe3cd
child 6632 6d7c4e8f0343b1b8ca5f6c4ad266be019b50f24f
push id4954
push userraliiev@mozilla.com
push dateTue, 22 Mar 2016 17:30:49 +0000
reviewersCallek
bugs1210536
Bug 1210536 - Use long hg revision in ship-it. r=Callek
buildfarm/release/release-runner.py
--- a/buildfarm/release/release-runner.py
+++ b/buildfarm/release/release-runner.py
@@ -93,16 +93,35 @@ def update_channels(version, mappings):
     ["release"]
     """
     for pattern, channels in mappings:
         if re.match(pattern, version):
             return channels
     raise RuntimeError("Cannot find update channels for %s" % version)
 
 
+def long_revision(repo, revision):
+    """Convert short revision to long using JSON API
+
+    >>> long_revision("releases/mozilla-beta", "59f372c35b24")
+    u'59f372c35b2416ac84d6572d64c49227481a8a6c'
+
+    >>> long_revision("releases/mozilla-beta", "59f372c35b2416ac84d6572d64c49227481a8a6c")
+    u'59f372c35b2416ac84d6572d64c49227481a8a6c'
+    """
+    url = "https://hg.mozilla.org/{}/json-rev/{}".format(repo, revision)
+
+    def _get():
+        req = requests.get(url, timeout=60)
+        req.raise_for_status()
+        return req.json()["node"]
+
+    return retry(_get)
+
+
 class ReleaseRunner(object):
     def __init__(self, api_root=None, username=None, password=None,
                  timeout=60):
         self.new_releases = []
         self.releases_api = Releases((username, password), api_root=api_root,
                                      timeout=timeout)
         self.release_api = Release((username, password), api_root=api_root,
                                    timeout=timeout)
@@ -112,18 +131,21 @@ class ReleaseRunner(object):
     def get_release_requests(self):
         new_releases = self.releases_api.getReleases()
         if new_releases['releases']:
             new_releases = [self.release_api.getRelease(name) for name in
                             new_releases['releases']]
             our_releases = [r for r in new_releases if
                             matches(r['name'], RELEASE_PATTERNS)]
             if our_releases:
+                # make sure to use long revision
+                for r in our_releases:
+                    r["mozillaRevision"] = long_revision(r["branch"], r["mozillaRevision"])
                 self.new_releases = our_releases
-                log.info("Releases to handle are %s", our_releases)
+                log.info("Releases to handle are %s", self.new_releases)
                 return True
             else:
                 log.info("No releases to handle in %s", new_releases)
                 return False
         else:
             log.info("No new releases: %s" % new_releases)
             return False