Commit ea2a57cd99d5f3b2c1ef27abbe2f5cb0c4084909
Exists in
spb-stable
and in
3 other branches
Merge branch 'improve/compare_page' into 'master'
Improve Compare page Prevent Compare page timout for large amount of commits. Fixes #989
Showing
5 changed files
with
34 additions
and
11 deletions
Show diff stats
CHANGELOG
1 | v 6.6.0 | 1 | v 6.6.0 |
2 | - Permissions: Developer now can manage issue tracker (modify any issue) | 2 | - Permissions: Developer now can manage issue tracker (modify any issue) |
3 | + - Improve Code Compare page performance | ||
3 | 4 | ||
4 | v 6.5.1 | 5 | v 6.5.1 |
5 | - Fix branch selectbox when create merge request from fork | 6 | - Fix branch selectbox when create merge request from fork |
app/assets/stylesheets/generic/lists.scss
app/controllers/projects/compare_controller.rb
@@ -8,7 +8,7 @@ class Projects::CompareController < Projects::ApplicationController | @@ -8,7 +8,7 @@ class Projects::CompareController < Projects::ApplicationController | ||
8 | end | 8 | end |
9 | 9 | ||
10 | def show | 10 | def show |
11 | - compare = Gitlab::Git::Compare.new(@repository.raw_repository, params[:from], params[:to]) | 11 | + compare = Gitlab::Git::Compare.new(@repository.raw_repository, params[:from], params[:to], MergeRequestDiff::COMMITS_SAFE_SIZE) |
12 | 12 | ||
13 | @commits = compare.commits | 13 | @commits = compare.commits |
14 | @commit = compare.commit | 14 | @commit = compare.commit |
@@ -16,6 +16,11 @@ class Projects::CompareController < Projects::ApplicationController | @@ -16,6 +16,11 @@ class Projects::CompareController < Projects::ApplicationController | ||
16 | @refs_are_same = compare.same | 16 | @refs_are_same = compare.same |
17 | @line_notes = [] | 17 | @line_notes = [] |
18 | 18 | ||
19 | + if @diffs == [Gitlab::Git::Diff::BROKEN_DIFF] | ||
20 | + @diffs = [] | ||
21 | + @timeout = true | ||
22 | + end | ||
23 | + | ||
19 | diff_line_count = Commit::diff_line_count(@diffs) | 24 | diff_line_count = Commit::diff_line_count(@diffs) |
20 | @suppress_diff = Commit::diff_suppress?(@diffs, diff_line_count) && !params[:force_show_diff] | 25 | @suppress_diff = Commit::diff_suppress?(@diffs, diff_line_count) && !params[:force_show_diff] |
21 | @force_suppress_diff = Commit::diff_force_suppress?(@diffs, diff_line_count) | 26 | @force_suppress_diff = Commit::diff_force_suppress?(@diffs, diff_line_count) |
app/views/projects/compare/_form.html.haml
@@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
14 | | 14 | |
15 | = submit_tag "Compare", class: "btn btn-create commits-compare-btn" | 15 | = submit_tag "Compare", class: "btn btn-create commits-compare-btn" |
16 | - if compare_to_mr_button? | 16 | - if compare_to_mr_button? |
17 | - = link_to compare_mr_path, class: 'prepend-left-10' do | 17 | + = link_to compare_mr_path, class: 'prepend-left-10 btn' do |
18 | %strong Make a merge request | 18 | %strong Make a merge request |
19 | 19 | ||
20 | 20 |
app/views/projects/compare/show.html.haml
@@ -5,21 +5,32 @@ | @@ -5,21 +5,32 @@ | ||
5 | 5 | ||
6 | = render "form" | 6 | = render "form" |
7 | 7 | ||
8 | -- if @commits.size > 100 | ||
9 | - .alert.alert-warning | ||
10 | - %p | ||
11 | - %strong Warning! This comparison includes more than 100 commits. | ||
12 | - %p To preserve performance the line diff is not shown. | ||
13 | - | ||
14 | - if @commits.present? | 8 | - if @commits.present? |
15 | %div.ui-box | 9 | %div.ui-box |
16 | .title | 10 | .title |
17 | Commits (#{@commits.count}) | 11 | Commits (#{@commits.count}) |
18 | - %ul.well-list= render Commit.decorate(@commits), project: @project | 12 | + - if @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE |
13 | + %ul.well-list | ||
14 | + - Commit.decorate(@commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE)).each do |commit| | ||
15 | + = render "projects/commits/inline_commit", commit: commit, project: @project | ||
16 | + %li.warning-row.unstyled | ||
17 | + other #{@commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE} commits hidden to prevent performance issues. | ||
18 | + - else | ||
19 | + %ul.well-list= render Commit.decorate(@commits), project: @project | ||
19 | 20 | ||
20 | - - unless @diffs.empty? | ||
21 | - %h4 Diff | 21 | + %h4 Diff |
22 | + - if @diffs.present? | ||
22 | = render "projects/commits/diffs", diffs: @diffs, project: @project | 23 | = render "projects/commits/diffs", diffs: @diffs, project: @project |
24 | + - elsif @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE | ||
25 | + .bs-callout.bs-callout-danger | ||
26 | + %h4 This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits. | ||
27 | + %p To preserve performance the line diff is not shown. | ||
28 | + - elsif @timeout | ||
29 | + .bs-callout.bs-callout-danger | ||
30 | + %h4 Diff for this comparison is extremely large. | ||
31 | + %p Use command line to browse diff for this comparison. | ||
32 | + | ||
33 | + | ||
23 | - else | 34 | - else |
24 | .light-well | 35 | .light-well |
25 | %center | 36 | %center |