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

HgGitRepository: avoid calling Gitaly for each SHA conversion

Spotted by the rate limit on Gitaly calls. We're simply caching
the result if it's positive.

branch : heptapod-stable
parent 49c095c70b60
......@@ -278,14 +278,24 @@ def git_sha_map
@git_sha_map ||= {|x| x.reverse }.to_h
# Useful for repetitive calls, and will cache only the `true` result
# Rationale: repetitive calls are typically for existing repositories.
# (disabling the cop because that's really what we want, and there's
# another cop preventing us to use a more explicit style)
# rubocop:disable Gitlab/PredicateMemoization
def cached_exists?
@cache_exists ||= exists?
# rubocop:enable Gitlab/PredicateMemoization
def sha_from_hgsha(hgsha)
return unless exists?
return unless cached_exists?
def hgsha_from_sha(sha)
return unless exists?
return unless cached_exists?
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