diff --git a/rhodecode/api/views/pull_request_api.py b/rhodecode/api/views/pull_request_api.py --- a/rhodecode/api/views/pull_request_api.py +++ b/rhodecode/api/views/pull_request_api.py @@ -725,8 +725,12 @@ def create_pull_request( # recalculate reviewers logic, to make sure we can validate this default_reviewers_data = get_default_reviewers_data( - owner, source_db_repo, - source_commit, target_db_repo, target_commit) + owner, + source_repo, + Reference(source_type, source_name, source_commit_id), + target_repo, + Reference(target_type, target_name, target_commit_id) + ) # now MERGE our given with the calculated reviewer_objects = default_reviewers_data['reviewers'] + reviewer_objects diff --git a/rhodecode/apps/repository/views/repo_review_rules.py b/rhodecode/apps/repository/views/repo_review_rules.py --- a/rhodecode/apps/repository/views/repo_review_rules.py +++ b/rhodecode/apps/repository/views/repo_review_rules.py @@ -72,9 +72,11 @@ class RepoReviewRulesView(RepoAppView): target_type = request.GET['target_ref_type'] target_name = request.GET['target_ref_name'] - source_ref = Reference(source_type, source_name, source_commit_id) - target_ref = Reference(target_type, target_name, target_commit_id) - review_data = get_default_reviewers_data( - current_user, source_repo, source_ref, target_repo, target_ref) + current_user, + source_repo, + Reference(source_type, source_name, source_commit_id), + target_repo, + Reference(target_type, target_name, target_commit_id) + ) return review_data diff --git a/rhodecode/model/pull_request.py b/rhodecode/model/pull_request.py --- a/rhodecode/model/pull_request.py +++ b/rhodecode/model/pull_request.py @@ -155,12 +155,21 @@ def get_diff_info( commits = [] if get_commit_authors: log.debug('Obtaining commit authors from set of commits') - commits = target_scm.compare( + _compare_data = target_scm.compare( target_ref, source_ref, source_scm, merge=True, - pre_load=["author", "date", "message", "branch", "parents"]) + pre_load=["author", "date", "message"] + ) - for commit in commits: - user = User.get_from_cs_author(commit.author) + for commit in _compare_data: + # NOTE(marcink): we serialize here, so we don't produce more vcsserver calls on data returned + # at this function which is later called via JSON serialization + serialized_commit = dict( + author=commit.author, + date=commit.date, + message=commit.message, + ) + commits.append(serialized_commit) + user = User.get_from_cs_author(serialized_commit['author']) if user and user not in commit_authors: commit_authors.append(user) @@ -170,14 +179,29 @@ def get_diff_info( target_commit = source_repo.get_commit(ancestor_id) for fname, lines in changed_lines.items(): + try: - node = target_commit.get_node(fname) + node = target_commit.get_node(fname, pre_load=["is_binary"]) except Exception: + log.exception("Failed to load node with path %s", fname) continue if not isinstance(node, FileNode): continue + # NOTE(marcink): for binary node we don't do annotation, just use last author + if node.is_binary: + author = node.last_commit.author + email = node.last_commit.author_email + + user = User.get_from_cs_author(author) + if user: + user_counts[user.user_id] = user_counts.get(user.user_id, 0) + 1 + author_counts[author] = author_counts.get(author, 0) + 1 + email_counts[email] = email_counts.get(email, 0) + 1 + + continue + for annotation in node.annotate: line_no, commit_id, get_commit_func, line_text = annotation if line_no in lines: