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

Operations: port over HGRC files from main repo to share

Closes #324

The specific repo configuration was ignored in all Mercurial
operations initiated by the Rails app.

I've considered making links instead of copying the file, but
it could give rise to funny situations if the original HGRC
files get changed in concurrency with some operation.

Edition of the HGRC files is by no means atomic in itself,
but that's a separate issue. On the other hand, operations can be
arbitrary long, involving several calls to the `hg` executable.
One would not want the rules to change in the middle of that.
parent c77b2b076cd5
Pipeline #8729 waiting for manual action with stage
......@@ -434,6 +434,19 @@
nil, env)
raise HgError, "Could not share repo at #{@hgpath} to #{share_path}: #{output}" if status != 0
%w[hgrc hgrc.managed].each do |fname|
src_hgrc_path = File.join(@hgpath, '.hg', fname)
if File.exist?(src_hgrc_path)
# FileUtils.copy_file happily overrides any existing file,
# and is just what FileUtils.cp calls in its loop (but `cp`
# for both files would expect them both to exist)
File.join(share_path, '.hg', fname))
rescue StandardError => exc
raise HgError, "Could not copy HGRC file .hg/#{fname} from #{@hgpath} to #{share_path}: #{exc.message}"
unless update_rev.nil?
output, status = popen([hg_exe, 'up', update_rev], share_path, env)
raise HgError, "Could not update shared repo to #{update_rev}: #{output}" if status != 0
Supports Markdown
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