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

HGitayRepository: fixing Diff invocations

Although they go trough `gitaly_commit_client` they actually
call the `DiffService`, not currently implemented by HGitaly at
all (obscure generic NoMethod gRPC error, hard to track which
caller it was).

We need to

- use @git_storage to call the regular Gitaly
- convert SHAs to Git SHAs

This gives us our first working Commit page in the Web UI, but only
for Commits without parents. In the (frequent, yes) general case,
we still need at least BatchByOids to display the Commit parents list
(must go partly through Markdown rendering). This last part will be
done after 0.17.0rc1

--HG--
branch : heptapod
parent 2605fa2b1a16
......@@ -211,11 +211,11 @@ def between(from, to)
def diff_stats(left_commit_sha, right_commit_sha)
request = Gitaly::DiffStatsRequest.new(
repository: @gitaly_repo,
left_commit_id: left_commit_sha,
right_commit_id: right_commit_sha
left_commit_id: @repository.fallbacking_gitsha_from_sha(left_commit_sha),
right_commit_id: @repository.fallbacking_gitsha_from_sha(right_commit_sha)
)
response = GitalyClient.call(@repository.storage, :diff_service, :diff_stats, request, timeout: GitalyClient.medium_timeout)
response = GitalyClient.call(@git_storage, :diff_service, :diff_stats, request, timeout: GitalyClient.medium_timeout)
response.flat_map(&:stats)
end
......@@ -417,8 +417,15 @@ def call_commit_diff(request_params, options = {})
request_params[:collapse_diffs] = !options.fetch(:expanded, true)
request_params.merge!(Gitlab::Git::DiffCollection.limits(options).to_h)
%i"left_commit_id right_commit_id".each do |k|
# incoming "ids" can be Git::EMPTY_TREE_ID or perhaps even
# non-sha revisions
request_params[k] = @repository.fallbacking_gitsha_from_sha(
request_params[k])
end
request = Gitaly::CommitDiffRequest.new(request_params)
response = GitalyClient.call(@repository.storage, :diff_service, :commit_diff, request, timeout: GitalyClient.medium_timeout)
response = GitalyClient.call(@git_storage, :diff_service, :commit_diff, request, timeout: GitalyClient.medium_timeout)
GitalyClient::DiffStitcher.new(response)
end
......
......@@ -88,6 +88,15 @@ def list_last_commits_for_tree(sha, path, **kwargs)
commits
end
# convert ids on the fly, for this through gitaly_commit_client
# that actually invokes the DiffService (not provided yet by HGitaly).
def diff_stats(left_id, right_id)
# incoming "ids" can be Git::EMPTY_TREE_ID or perhaps even
# non-sha revisions
super(fallbacking_gitsha_from_sha(left_id),
fallbacking_gitsha_from_sha(right_id))
end
def gitaly_ref_client
@gitaly_ref_client ||= Gitlab::GitalyClient::RefService.new(self, vcs: 'hg')
end
......
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