Commit 2585fddc authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

housekeeping: running `hg recover` systematically

It's cheap and it can unblock a repo.

--HG--
branch : heptapod-stable
parent a53cdbad8015
......@@ -94,6 +94,7 @@ def flush_ref_caches(project)
## `repository` has to be a Gitlab::Mercurial::(HgGit)Repository
def hg_housekeeping(task, repository)
repository.hg_recover
case task
when :full_repack
repository.hg_optim
......
......@@ -181,6 +181,23 @@ def hg_optim
end
end
# Run `hg recover`.
# This is idempotent and reasonably fast if there's nothing to recover
def hg_recover
hg_env = {'HGUSER' => 'Heptapod system',
'HEPTAPOD_SKIP_ALL_GITLAB_HOOKS' => 'yes',
'HGRCPATH' => Gitlab::Mercurial.hgrc_path,
}
output, status = popen(
[Gitlab.config.mercurial.bin_path,
"recover",
], @hgpath, hg_env)
# as usual with hg, code 1 means there's nothing to do
unless [0, 1].include?(status)
raise HgError, "`hg recover` failed for #{@hgpath}: " + output
end
end
def rename(new_git_relative_path)
super(new_git_relative_path)
new_hg_relative_path = new_git_relative_path.sub(/\.git$/, '.hg')
......
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