Bug 894072 - Sync gaia to the commit specified in gaia.json, r=aki
authorJonathan Griffin <jgriffin@mozilla.com>
Wed, 17 Jul 2013 09:24:55 -0700
changeset 1704 0b00f2c7056aa4fa4d956cf4cb4d4c9019abcad0
parent 1701 cd4d1493f2aa127f4737549b5f68cecc61b2d7d2
child 1705 d35e9da9fe3dcf4052f194dd7ddf64685ffd99f8
child 1706 c7c0c5cd4cbcc84886de4ed4cca16c8920a7cc25
push id1117
push userjgriffin@mozilla.com
push dateWed, 17 Jul 2013 16:25:09 +0000
reviewersaki
bugs894072
Bug 894072 - Sync gaia to the commit specified in gaia.json, r=aki
scripts/gaia_unit.py
--- a/scripts/gaia_unit.py
+++ b/scripts/gaia_unit.py
@@ -11,24 +11,25 @@ import re
 import sys
 
 # load modules from parent dir
 sys.path.insert(1, os.path.dirname(sys.path[0]))
 
 from mozharness.base.errors import TarErrorList, ZipErrorList, HgErrorList
 from mozharness.base.log import INFO, ERROR, WARNING, FATAL
 from mozharness.base.script import PreScriptAction
+from mozharness.base.transfer import TransferMixin
 from mozharness.base.vcs.vcsbase import MercurialScript
 from mozharness.mozilla.buildbot import TBPL_SUCCESS, TBPL_WARNING, TBPL_FAILURE
 from mozharness.mozilla.testing.testbase import TestingMixin, testing_config_options
 from mozharness.mozilla.testing.unittest import TestSummaryOutputParserHelper
 from mozharness.mozilla.tooltool import TooltoolMixin
 
 
-class GaiaUnitTest(TestingMixin, TooltoolMixin, MercurialScript):
+class GaiaUnitTest(TestingMixin, TooltoolMixin, MercurialScript, TransferMixin):
     config_options = [
         [["--gaia-dir"],
          {"action": "store",
           "dest": "gaia_dir",
           "default": None,
           "help": "directory where gaia repo should be cloned"
          }],
         [["--gaia-repo"],
@@ -87,20 +88,39 @@ class GaiaUnitTest(TestingMixin, Tooltoo
         c = self.config
         self.installer_url = c.get('installer_url')
         self.installer_path = c.get('installer_path')
         self.binary_path = c.get('binary_path')
 
     def pull(self, **kwargs):
         dirs = self.query_abs_dirs()
         repos = copy.deepcopy(self.config.get('repos', []))
-        repos.append({'repo': self.config.get('gaia_repo'),
-                      'revision': 'default',
+
+        gaia_repo_path = self.config.get('gaia_repo')
+        gaia_revision = 'default'
+        gaia_branch = self.config.get('gaia_branch')
+
+        if self.buildbot_config is not None:
+            # get gaia commit via hgweb
+            revision = self.buildbot_config['properties']['revision']
+            repo_path = self.buildbot_config['properties']['repo_path']
+            url = "https://hg.mozilla.org/{repo_path}/raw-file/{rev}/b2g/config/gaia.json".format(
+                repo_path=repo_path,
+                rev=revision)
+            contents = self.retry(self.load_json_from_url, args=(url,))
+            if contents.get('repo_path') and contents.get('revision'):
+                gaia_repo_path = 'https://hg.mozilla.org/%s' % contents['repo_path']
+                gaia_revision = contents['revision']
+                gaia_branch = None
+
+        repos.append({'repo': gaia_repo_path,
+                      'revision': gaia_revision,
                       'dest': 'gaia',
-                      'branch': self.config.get('gaia_branch')})
+                      'branch': gaia_branch})
+
         for repo in repos:
             dest = None
             if repo.get('dest') == 'gaia':
                 dest = os.path.dirname(dirs['abs_gaia_dir'])
                 repo_dir = os.path.join(dest, 'gaia')
 
                 # purge the repo if it already exists
                 if os.access(repo_dir, os.F_OK):