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
--- 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()