##// END OF EJS Templates
reviewers: optimize diff data, and creation of PR with advanced default reviewers
marcink -
r4510:b532b1b7 stable
parent child Browse files
Show More
@@ -725,8 +725,12 b' def create_pull_request('
725
725
726 # recalculate reviewers logic, to make sure we can validate this
726 # recalculate reviewers logic, to make sure we can validate this
727 default_reviewers_data = get_default_reviewers_data(
727 default_reviewers_data = get_default_reviewers_data(
728 owner, source_db_repo,
728 owner,
729 source_commit, target_db_repo, target_commit)
729 source_repo,
730 Reference(source_type, source_name, source_commit_id),
731 target_repo,
732 Reference(target_type, target_name, target_commit_id)
733 )
730
734
731 # now MERGE our given with the calculated
735 # now MERGE our given with the calculated
732 reviewer_objects = default_reviewers_data['reviewers'] + reviewer_objects
736 reviewer_objects = default_reviewers_data['reviewers'] + reviewer_objects
@@ -72,9 +72,11 b' class RepoReviewRulesView(RepoAppView):'
72 target_type = request.GET['target_ref_type']
72 target_type = request.GET['target_ref_type']
73 target_name = request.GET['target_ref_name']
73 target_name = request.GET['target_ref_name']
74
74
75 source_ref = Reference(source_type, source_name, source_commit_id)
76 target_ref = Reference(target_type, target_name, target_commit_id)
77
78 review_data = get_default_reviewers_data(
75 review_data = get_default_reviewers_data(
79 current_user, source_repo, source_ref, target_repo, target_ref)
76 current_user,
77 source_repo,
78 Reference(source_type, source_name, source_commit_id),
79 target_repo,
80 Reference(target_type, target_name, target_commit_id)
81 )
80 return review_data
82 return review_data
@@ -155,12 +155,21 b' def get_diff_info('
155 commits = []
155 commits = []
156 if get_commit_authors:
156 if get_commit_authors:
157 log.debug('Obtaining commit authors from set of commits')
157 log.debug('Obtaining commit authors from set of commits')
158 commits = target_scm.compare(
158 _compare_data = target_scm.compare(
159 target_ref, source_ref, source_scm, merge=True,
159 target_ref, source_ref, source_scm, merge=True,
160 pre_load=["author", "date", "message", "branch", "parents"])
160 pre_load=["author", "date", "message"]
161 )
161
162
162 for commit in commits:
163 for commit in _compare_data:
163 user = User.get_from_cs_author(commit.author)
164 # NOTE(marcink): we serialize here, so we don't produce more vcsserver calls on data returned
165 # at this function which is later called via JSON serialization
166 serialized_commit = dict(
167 author=commit.author,
168 date=commit.date,
169 message=commit.message,
170 )
171 commits.append(serialized_commit)
172 user = User.get_from_cs_author(serialized_commit['author'])
164 if user and user not in commit_authors:
173 if user and user not in commit_authors:
165 commit_authors.append(user)
174 commit_authors.append(user)
166
175
@@ -170,14 +179,29 b' def get_diff_info('
170 target_commit = source_repo.get_commit(ancestor_id)
179 target_commit = source_repo.get_commit(ancestor_id)
171
180
172 for fname, lines in changed_lines.items():
181 for fname, lines in changed_lines.items():
182
173 try:
183 try:
174 node = target_commit.get_node(fname)
184 node = target_commit.get_node(fname, pre_load=["is_binary"])
175 except Exception:
185 except Exception:
186 log.exception("Failed to load node with path %s", fname)
176 continue
187 continue
177
188
178 if not isinstance(node, FileNode):
189 if not isinstance(node, FileNode):
179 continue
190 continue
180
191
192 # NOTE(marcink): for binary node we don't do annotation, just use last author
193 if node.is_binary:
194 author = node.last_commit.author
195 email = node.last_commit.author_email
196
197 user = User.get_from_cs_author(author)
198 if user:
199 user_counts[user.user_id] = user_counts.get(user.user_id, 0) + 1
200 author_counts[author] = author_counts.get(author, 0) + 1
201 email_counts[email] = email_counts.get(email, 0) + 1
202
203 continue
204
181 for annotation in node.annotate:
205 for annotation in node.annotate:
182 line_no, commit_id, get_commit_func, line_text = annotation
206 line_no, commit_id, get_commit_func, line_text = annotation
183 if line_no in lines:
207 if line_no in lines:
General Comments 0
You need to be logged in to leave comments. Login now