Bug 1429094 - Define the environment variable HGRCPATH to ignore any .hgrc that may exist r=gps draft
authorJulien Wajsberg <felash@gmail.com>
Tue, 09 Jan 2018 16:48:24 +0100
changeset 718990 e2fb4bb160977c3e8857b7cc1a3f19671c77bfa3
parent 715663 f78a83244fbebe8a469ae3512fce7f638cab7e1f
child 745680 02d13d81fd4bd01720210d591e2cc3b0b1011f02
push id95133
push userbmo:felash@gmail.com
push dateThu, 11 Jan 2018 10:31:26 +0000
reviewersgps
bugs1429094
milestone59.0a1
Bug 1429094 - Define the environment variable HGRCPATH to ignore any .hgrc that may exist r=gps By ignoring existing .hgrc we make sure we don't try to load extensions and have a consistent output. Especially we won't have error messages that could confuse us into extracting a wrong version number. MozReview-Commit-ID: FwrfcbY8QpN
python/mozboot/mozboot/base.py
--- a/python/mozboot/mozboot/base.py
+++ b/python/mozboot/mozboot/base.py
@@ -442,35 +442,39 @@ class BaseBootstrapper(object):
                                  stderr=subprocess.STDOUT)
         match = re.search(name + ' ([a-z0-9\.]+)', info)
         if not match:
             print('ERROR! Unable to identify %s version.' % name)
             return None
 
         return LooseVersion(match.group(1))
 
-    def _hgplain_env(self):
+    def _hg_cleanenv(self):
         """ Returns a copy of the current environment updated with the HGPLAIN
-        environment variable.
+        and HGRCPATH environment variables.
 
         HGPLAIN prevents Mercurial from applying locale variations to the output
         making it suitable for use in scripts.
+
+        HGRCPATH controls the loading of hgrc files. Setting it to the empty
+        string forces that no user or system hgrc file is used.
         """
         env = os.environ.copy()
         env[b'HGPLAIN'] = b'1'
+        env[b'HGRCPATH'] = b''
 
         return env
 
     def is_mercurial_modern(self):
         hg = self.which('hg')
         if not hg:
             print(NO_MERCURIAL)
             return False, False, None
 
-        our = self._parse_version(hg, 'version', self._hgplain_env())
+        our = self._parse_version(hg, 'version', self._hg_cleanenv())
         if not our:
             return True, False, None
 
         return True, our >= MODERN_MERCURIAL_VERSION, our
 
     def ensure_mercurial_modern(self):
         installed, modern, version = self.is_mercurial_modern()