Bug 1419128 - Remove functionality for downloading mozconfigs; r?build draft
authorGregory Szorc <gps@mozilla.com>
Mon, 20 Nov 2017 14:18:46 -0800
changeset 700808 c92199f27944f0871b72595b18f49cdcf0738640
parent 700807 6b6fb08db8c46a4fd75822326543fb63a903daea
child 700809 e85fd0045fd81976d57a086e978ec099b4da4370
push id89984
push userbmo:gps@mozilla.com
push dateMon, 20 Nov 2017 23:14:50 +0000
reviewersbuild
bugs1419128
milestone59.0a1
Bug 1419128 - Remove functionality for downloading mozconfigs; r?build Pretty sure this is a relic of running this check in automation outside the context of a source check. compare-mozconfigs.py is essentially a source lint. I don't see a need for this feature to exist.
build/compare-mozconfig/compare-mozconfigs-wrapper.py
build/compare-mozconfig/compare-mozconfigs.py
--- a/build/compare-mozconfig/compare-mozconfigs-wrapper.py
+++ b/build/compare-mozconfig/compare-mozconfigs-wrapper.py
@@ -38,22 +38,22 @@ class TestCompareMozconfigs(unittest.Tes
             script_path = path.join(topsrcdir, 'build/compare-mozconfig/compare-mozconfigs.py')
             whitelist_path = path.join(browser_dir, 'config/mozconfigs/whitelist')
             beta_mozconfig_path = path.join(browser_dir, 'config/mozconfigs', platform, 'beta')
             release_mozconfig_path = path.join(browser_dir, 'config/mozconfigs', platform, 'release')
             nightly_mozconfig_path = path.join(browser_dir, 'config/mozconfigs', platform, 'nightly')
 
             log.info("Comparing beta against nightly mozconfigs")
             ret_code = subprocess.call([python_exe, script_path, '--whitelist',
-                                        whitelist_path, '--no-download',
+                                        whitelist_path,
                                         platform + ',' + beta_mozconfig_path +
                                         ',' + nightly_mozconfig_path])
             self.assertEqual(0, ret_code)
 
             log.info("Comparing release against nightly mozconfigs")
             ret_code = subprocess.call([python_exe, script_path, '--whitelist',
-                                        whitelist_path, '--no-download',
+                                        whitelist_path,
                                         platform + ',' + release_mozconfig_path +
                                         ',' + nightly_mozconfig_path])
             self.assertEqual(0, ret_code)
 
 if __name__ == '__main__':
     mozunit.main()
--- a/build/compare-mozconfig/compare-mozconfigs.py
+++ b/build/compare-mozconfig/compare-mozconfigs.py
@@ -4,43 +4,26 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # originally from https://hg.mozilla.org/build/tools/file/4ab9c1a4e05b/scripts/release/compare-mozconfigs.py
 
 from __future__ import unicode_literals
 
 import logging
 import sys
-import urllib2
 import difflib
 
 FAILURE_CODE = 1
 SUCCESS_CODE = 0
 
 log = logging.getLogger(__name__)
 
 class ConfigError(Exception):
     pass
 
-def make_hg_url(hgHost, repoPath, protocol='https', revision=None,
-                filename=None):
-    """construct a valid hg url from a base hg url (hg.mozilla.org),
-    repoPath, revision and possible filename"""
-    base = '%s://%s' % (protocol, hgHost)
-    repo = '/'.join(p.strip('/') for p in [base, repoPath])
-    if not filename:
-        if not revision:
-            return repo
-        else:
-            return '/'.join([p.strip('/') for p in [repo, 'rev', revision]])
-    else:
-        assert revision
-        return '/'.join([p.strip('/') for p in [repo, 'raw-file', revision,
-                         filename]])
-
 def readConfig(configfile):
     c = {}
     execfile(configfile, c)
     return c['whitelist']
 
 def verify_mozconfigs(mozconfig_pair, nightly_mozconfig_pair, platform,
                       mozconfigWhitelist):
     """Compares mozconfig to nightly_mozconfig and compare to an optional
@@ -99,54 +82,37 @@ def verify_mozconfigs(mozconfig_pair, ni
                 log.error(message % (mozconfig_name,
                                      nightly_mozconfig_name, clean_line))
             else:
                 log.error(message % (nightly_mozconfig_name,
                                      mozconfig_name, clean_line))
             success = False
     return success
 
-def get_mozconfig(path, options):
-    """Consumes a path and returns a list of lines from
-    the mozconfig file. If download is required, the path
-    specified should be relative to the root of the hg
-    repository e.g browser/config/mozconfigs/linux32/nightly"""
-    if options.no_download:
-        return open(path, 'r').readlines()
-    else:
-        url = make_hg_url(options.hghost, options.branch, 'http',
-                    options.revision, path)
-        return urllib2.urlopen(url).readlines()
+def get_mozconfig(path):
+    """Consumes a path and returns a list of lines from the mozconfig file."""
+    with open(path, 'rb') as fh:
+        return fh.readlines()
 
 if __name__ == '__main__':
     from optparse import OptionParser
     parser = OptionParser()
 
-    parser.add_option('--branch', dest='branch')
-    parser.add_option('--revision', dest='revision')
-    parser.add_option('--hghost', dest='hghost', default='hg.mozilla.org')
     parser.add_option('--whitelist', dest='whitelist')
-    parser.add_option('--no-download', action='store_true', dest='no_download',
-                      default=False)
     options, args = parser.parse_args()
 
     logging.basicConfig(level=logging.INFO)
 
-    missing_args = options.branch is None or options.revision is None
-    if not options.no_download and missing_args:
-        logging.error('Not enough arguments to download mozconfigs')
-        sys.exit(FAILURE_CODE)
-
     mozconfig_whitelist = readConfig(options.whitelist)
 
     for arg in args:
         platform, mozconfig_path, nightly_mozconfig_path = arg.split(',')
 
-        mozconfig_lines = get_mozconfig(mozconfig_path, options)
-        nightly_mozconfig_lines = get_mozconfig(nightly_mozconfig_path, options)
+        mozconfig_lines = get_mozconfig(mozconfig_path)
+        nightly_mozconfig_lines = get_mozconfig(nightly_mozconfig_path)
 
         mozconfig_pair = (mozconfig_path, mozconfig_lines)
         nightly_mozconfig_pair = (nightly_mozconfig_path,
                                   nightly_mozconfig_lines)
 
         passed = verify_mozconfigs(mozconfig_pair, nightly_mozconfig_pair,
                                    platform, mozconfig_whitelist)