Bug 1629115 - Use virtualenv python for git-cinnabar. r=dhouse
authorMike Hommey <mh@glandium.org>
Wed, 15 Apr 2020 06:24:32 +0900
changeset 4487 f9e15479984a94a7cdd03fa6fc6c0b6b94ac2852
parent 4486 9e1dce7755d0a6b1ba7e88140d1fe523f89cf283
child 4488 904f897a1305a6a2dc02cfe754f006a7da37605d
push id3590
push usermh@glandium.org
push dateThu, 16 Apr 2020 21:42:48 +0000
reviewersdhouse
bugs1629115
Bug 1629115 - Use virtualenv python for git-cinnabar. r=dhouse
scripts/vcs-sync/vcs_sync.py
--- a/scripts/vcs-sync/vcs_sync.py
+++ b/scripts/vcs-sync/vcs_sync.py
@@ -907,42 +907,50 @@ intree=1
                 repo_map['repos'][repo_name]['branches'][branch]['git_revision'] = git_revision
         self._write_repo_update_json(repo_map)
 
     def _update_cinnabar_mirror(self, repo_config, git, dest, generated_mapfile):
         # Do things somewhat equivalent to hg gexport with git-cinnabar, which involves:
         # - converting new hg changesets
         # - update tags
         # - update .hg/git-mapfile
+        partial_env = {
+            'PATH': os.pathsep.join([
+                os.path.join(self.query_virtualenv_path(), 'bin'),
+                os.environ['PATH'],
+            ]),
+        }
         if self.retry(
             self.run_command,
             args=(git + [
                 '-c', 'gc.auto=0',
                 '-c', 'cinnabar.refs=bookmarks',
                 '-c', 'cinnabar.check=no-version-check',
                 'fetch', '--progress', 'hg::%s' % dest, 'refs/heads/*:refs/heads/*'], ),
             kwargs={
                 'output_timeout': repo_config.get("export_timeout", 120 * 60),
                 'cwd': dest,
                 'error_list': GitErrorList,
+                'partial_env': partial_env,
             },
             error_level=FATAL,
         ):
             self.fatal('Error converting from mercurial to git')
 
         if self.retry(
             self.run_command,
             args=(git + [
                 '-c', 'gc.auto=0',
                 '-c', 'cinnabar.check=no-version-check',
                 'fetch', '--tags', 'hg::tags:', 'tag', '*'], ),
             kwargs={
                 'output_timeout': 60,
                 'cwd': dest,
                 'error_list': GitErrorList,
+                'partial_env': partial_env,
             },
             error_level=FATAL,
         ):
             self.fatal('Error converting tags')
 
         # Extra cleanup step: if there are more than 6700 loose objects or more than 50 packs,
         # repack everything.
         self.retry(
@@ -977,20 +985,23 @@ intree=1
         # changeset ids.
         output = self.get_output_from_command(
             git + ['diff-tree', '-r', 'refs/cinnabar/map^4', 'refs/cinnabar/metadata^4'],
             cwd=dest,
         )
         git_sha1s = [diff_line.split()[-1].replace('/', '') for diff_line in (output or '').splitlines()]
         hg_sha1s = []
         CHUNK_SIZE = 50
+        env = os.environ.copy()
+        env.update(partial_env)
         for offset in range(0, len(git_sha1s), CHUNK_SIZE):
             output = self.get_output_from_command(
                 git + ['-c', 'cinnabar.check=no-version-check', 'cinnabar', 'git2hg'] + git_sha1s[offset:offset + CHUNK_SIZE],
                 cwd=dest,
+                env=env,
             )
             hg_sha1s += (output or '').split()
         if len(git_sha1s) != len(hg_sha1s) or '0000000000000000000000000000000000000000' in hg_sha1s:
             self.fatal('Error while updating git->hg mapping')
 
         # Nothing to update, we can return now
         if not git_sha1s:
             return