Bug 1583234 - Set HGPLAIN when running hg during an artifact build. r=nalexander
authorChris Manchester <cmanchester@mozilla.com>
Mon, 30 Sep 2019 21:35:40 +0000
changeset 2360189 e72742f591f8997ac73863ad321f66a353923076
parent 2360188 b08fca6e85e747cb2e3422917ae04220d22e1444
child 2360190 50283c4e0a1012eae1d917b7fc1775a366597b10
push id429418
push userkjacobs@mozilla.com
push dateMon, 30 Sep 2019 23:05:57 +0000
treeherdertry@46e474c475cc [default view] [failures only]
reviewersnalexander
bugs1583234
milestone71.0a1
Bug 1583234 - Set HGPLAIN when running hg during an artifact build. r=nalexander Differential Revision: https://phabricator.services.mozilla.com/D47656
python/mozbuild/mozbuild/artifacts.py
--- a/python/mozbuild/mozbuild/artifacts.py
+++ b/python/mozbuild/mozbuild/artifacts.py
@@ -874,16 +874,23 @@ class Artifacts(object):
             self._cache_dir, log=self._log, skip_cache=self._skip_cache)
         self._pushhead_cache = PushheadCache(
             self._cache_dir, log=self._log, skip_cache=self._skip_cache)
 
     def log(self, *args, **kwargs):
         if self._log:
             self._log(*args, **kwargs)
 
+    def run_hg(self, *args, **kwargs):
+        env = kwargs.get('env', {})
+        env['HGPLAIN'] = '1'
+        kwargs['env'] = env
+        return subprocess.check_output([self._hg] + list(args),
+                                       **kwargs)
+
     def _guess_artifact_job(self):
         # Add the "-debug" suffix to the guessed artifact job name
         # if MOZ_DEBUG is enabled.
         if self._substs.get('MOZ_DEBUG'):
             target_suffix = '-debug'
         elif self._substs.get('MOZ_PGO'):
             target_suffix = '-pgo'
         else:
@@ -980,22 +987,20 @@ class Artifacts(object):
 
         If we're using git, retrieves hg revisions from git-cinnabar.
         """
         if self._git:
             return self._get_hg_revisions_from_git()
 
         # Mercurial updated the ordering of "last" in 4.3. We use revision
         # numbers to order here to accommodate multiple versions of hg.
-        last_revs = subprocess.check_output([
-            self._hg, 'log',
-            '--template', '{rev}:{node}\n',
-            '-r', 'last(public() and ::., {num})'.format(
-                num=NUM_REVISIONS_TO_QUERY)
-        ], cwd=self._topsrcdir).splitlines()
+        last_revs = self.run_hg('log', '--template', '{rev}:{node}\n',
+                                '-r', 'last(public() and ::., {num})'.format(
+                                    num=NUM_REVISIONS_TO_QUERY),
+                                cwd=self._topsrcdir).splitlines()
 
         if len(last_revs) == 0:
             raise Exception("""\
 There are no public revisions.
 This can happen if the repository is created from bundle file and never pulled
 from remote.  Please run `hg pull` and build again.
 see https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Source_Code/Mercurial/Bundles\
 """)
@@ -1172,18 +1177,18 @@ see https://developer.mozilla.org/en-US/
     def install_from_recent(self, distdir):
         hg_pushheads = self._find_pushheads()
         return self._install_from_hg_pushheads(hg_pushheads, distdir)
 
     def install_from_revset(self, revset, distdir):
         revision = None
         try:
             if self._hg:
-                revision = subprocess.check_output([self._hg, 'log', '--template', '{node}\n',
-                                                    '-r', revset], cwd=self._topsrcdir).strip()
+                revision = self.run_hg('log', '--template', '{node}\n', '-r', revset,
+                                       cwd=self._topsrcdir).strip()
             elif self._git:
                 revset = subprocess.check_output([
                     self._git, 'rev-parse', '%s^{commit}' % revset],
                     stderr=open(os.devnull, 'w'), cwd=self._topsrcdir).strip()
             else:
                 # Fallback to the exception handling case from both hg and git
                 raise subprocess.CalledProcessError()
         except subprocess.CalledProcessError: