testing: separate global config in MozReview Mercurial server
authorGregory Szorc <gps@mozilla.com>
Sat, 24 Jan 2015 14:42:51 -0800
changeset 360250 4ce900443d4b6b2160760c2faa1b59162826aaf2
parent 360249 b6b821618fe13e819c8bef4c2c1c09655a33c5e0
child 360251 3f3ebf296c08789a3e076b693002894d382c492b
push id16998
push userrwood@mozilla.com
push dateMon, 02 May 2016 19:42:03 +0000
testing: separate global config in MozReview Mercurial server We refactor the configuration of the Mercurial server in MozReview instances such that the global configuration is different from the web configuration. This simulates how things work in production, which a global hgrc (typically /etc/mercurial/hgrc) provides global defaults and a web config file provides the web configuration. These don't strictly need to be separate files. But it helps keep logic sorted out. And considering Mercurial's behavior of only reading a whitelist of options from web.conf files, it makes sense to keep a wall between them to avoid ambiguity.
testing/vcttesting/mozreview.py
--- a/testing/vcttesting/mozreview.py
+++ b/testing/vcttesting/mozreview.py
@@ -213,35 +213,40 @@ class MozReview(object):
                 'url = %s' % self.reviewboard_url,
                 '',
                 '[extensions]',
                 'reviewboard = %s' % rb_ext_path,
                 '',
                 '[bugzilla]',
                 'url = %s' % self.bugzilla_url,
                 '',
+            ]))
+
+        web_conf = os.path.join(self._path, 'web.conf')
+        with open(web_conf, 'w') as fh:
+            fh.write('\n'.join([
                 '[web]',
                 'push_ssl = False',
                 'allow_push = *',
                 '',
                 '[paths]',
                 '/ = %s/**' % repos_path,
                 '',
             ]))
 
         env = os.environ.copy()
-        env['HGRCPATH'] = '/dev/null'
+        env['HGRCPATH'] = global_hgrc
         env['HGENCODING'] = 'UTF-8'
         args = [
             self._hg,
             'serve',
             '-d',
             '-p', str(port),
             '--pid-file', self._hg_pid_path,
-            '--web-conf', global_hgrc,
+            '--web-conf', web_conf,
             '--accesslog', os.path.join(self._path, 'hg.access.log'),
             '--errorlog', os.path.join(self._path, 'hg.error.log'),
         ]
         # We execute from / so Mercurial doesn't pick up config files
         # from parent directories.
         subprocess.check_call(args, env=env, cwd='/')
 
         with open(self._hg_pid_path, 'rb') as fh: