Commit 164619af authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

HgGitRepository: avoid exception on empty repo

As explained in the comment, we can have some conversion attempts
while the repo is empty and has no map file.

Specifically, this fixes fil creation from the Rails app on
empty repositories.

--HG--
branch : heptapod
parent 23bd45dee3c4
......@@ -276,6 +276,19 @@ def hg_sha_map
end
.to_h
end
rescue Errno::ENOENT
# This can happen on rare occasions.
#
# Logically that means the correspondence is empty, but let's not cache it
# so that we won't need exceptional cache invalidations
#
# For instance, Lfs::FileTransformer.lfs_file?
# (called from Files::CreateService) queries tree/blob attributes while
# it's not guaranteed yet that the repo isn't empty. In the current state
# of Mercurial native projects (before HGitaly2 developments have even
# started), this goes through Git Tree/Blob lookups... and a conversion
# of Mercurial SHAs to Git that must not raise unexpected exceptions.
{}
end
def git_sha_map
......
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