Commit c706aad5 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Native Mercurial: flag was not passed to all `hg` subprocesses

It was correctly passed only from methods that use `hg_env_for_write`.

Closes #548

Notably, it didn't occur during initial import, which is `hg pull` done
on custom environment derived from `hg_env_minimal`.

--HG--
branch : heptapod-stable
parent c24d4cb7d409
Pipeline #27948 passed with stages
in 30 minutes and 31 seconds
......@@ -379,7 +379,8 @@ def hg_changeset_branch_topic(hgsha)
end
def hg_env_minimal
env = { 'HGRCPATH' => Gitlab::Mercurial.hgrc_path }
env = { 'HGRCPATH' => Gitlab::Mercurial.hgrc_path,
'HEPTAPOD_HG_NATIVE' => 'no' }
hg_mod_pol = Gitlab.config.mercurial.module_policy
env['HGMODULEPOLICY'] = hg_mod_pol unless hg_mod_pol.nil?
env
......@@ -412,7 +413,6 @@ def hg_env_for_write(user, force_system_user: false)
'HEPTAPOD_USERINFO_USERNAME' => user&.username,
'HEPTAPOD_USERINFO_NAME' => user&.name,
'HEPTAPOD_USERINFO_EMAIL' => user&.email,
'HEPTAPOD_HG_NATIVE' => 'no',
'GL_REPOSITORY' => @gl_repository,
'HGUSER' => nil
})
......
......@@ -79,8 +79,8 @@ def commit_id_from_display_id(display_id)
display_id
end
override :hg_env_for_write
def hg_env_for_write(*args, **kwargs)
override :hg_env_minimal
def hg_env_minimal(*args, **kwargs)
res = super
res['HEPTAPOD_HG_NATIVE'] = 'yes'
res
......
......@@ -54,6 +54,27 @@
it { is_expected.to respond_to(:hg_sha_map) }
end
describe "#hg_call" do
subject { mutable_repository }
it "spawns hg process having heptapod.native=no with the default environment variables" do
output, _status = subject.hg_call(['config', 'heptapod.native'])
expect(output.strip).to eq("no")
end
it "spawns hg process having heptapod.native=no with the write environment variables" do
output, _status = subject.hg_call(['config', 'heptapod.native'],
env: subject.hg_env_for_write(user))
expect(output.strip).to eq("no")
end
it "spawns hg process having heptapod.native=no with the minimal environment variables" do
output, _status = subject.hg_call(['config', 'heptapod.native'],
env: subject.hg_env_minimal)
expect(output.strip).to eq("no")
end
end
describe "#hg_changeset_branch" do
subject { non_empty_repository }
......
......@@ -54,6 +54,27 @@
let(:non_empty_repository_path) { repository_path }
describe "#hg_call" do
subject { repository }
it "spawns hg process having heptapod.native=no with the default environment variables" do
output, _status = subject.hg_call(['config', 'heptapod.native'])
expect(output.strip).to eq("yes")
end
it "spawns hg process having heptapod.native=no with the write environment variables" do
output, _status = subject.hg_call(['config', 'heptapod.native'],
env: subject.hg_env_for_write(user))
expect(output.strip).to eq("yes")
end
it "spawns hg process having heptapod.native=no with the minimal environment variables" do
output, _status = subject.hg_call(['config', 'heptapod.native'],
env: subject.hg_env_minimal)
expect(output.strip).to eq("yes")
end
end
describe '#branch_names' do
subject { non_empty_repository }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment