From 68249f23dacbddf61ca296a7decf98ecf6fc16fb Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 5 Feb 2014 15:54:51 +0200 Subject: [PATCH 1/3] Prevent Compare page timout for large amount of commits Signed-off-by: Dmitriy Zaporozhets --- CHANGELOG | 1 + app/assets/stylesheets/generic/lists.scss | 6 ++++++ app/views/projects/compare/show.html.haml | 9 ++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 06008e78d6..57a89a4c17 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ v 6.6.0 - Permissions: Developer now can manage issue tracker (modify any issue) + - Improve Code Compare page performance v 6.5.1 - Fix branch selectbox when create merge request from fork diff --git a/app/assets/stylesheets/generic/lists.scss b/app/assets/stylesheets/generic/lists.scss index 245cccf855..de70e47333 100644 --- a/app/assets/stylesheets/generic/lists.scss +++ b/app/assets/stylesheets/generic/lists.scss @@ -23,6 +23,12 @@ } } + &.warning-row { + background-color: #fcf8e3; + border-color: #faebcc; + color: #8a6d3b; + } + &.smoke { background-color: #f5f5f5; } &:hover { diff --git a/app/views/projects/compare/show.html.haml b/app/views/projects/compare/show.html.haml index e9456c2496..6b0b12a3ee 100644 --- a/app/views/projects/compare/show.html.haml +++ b/app/views/projects/compare/show.html.haml @@ -15,7 +15,14 @@ %div.ui-box .title Commits (#{@commits.count}) - %ul.well-list= render Commit.decorate(@commits), project: @project + - if @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE + %ul.well-list + - Commit.decorate(@commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE)).each do |commit| + = render "projects/commits/inline_commit", commit: commit, project: @project + %li.warning-row.unstyled + other #{@commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE} commits hidden to prevent performance issues. + - else + %ul.well-list= render Commit.decorate(@commits), project: @project - unless @diffs.empty? %h4 Diff From 8f88cbf06bce7e88b9a4470645665b65ca543946 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 5 Feb 2014 16:09:13 +0200 Subject: [PATCH 2/3] Use MergeRequestDiff::COMMITS_SAFE_SIZE for Compare diff limit. Signed-off-by: Dmitriy Zaporozhets --- app/controllers/projects/compare_controller.rb | 2 +- app/views/projects/compare/_form.html.haml | 2 +- app/views/projects/compare/show.html.haml | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb index b7531e2cef..02fcb8d255 100644 --- a/app/controllers/projects/compare_controller.rb +++ b/app/controllers/projects/compare_controller.rb @@ -8,7 +8,7 @@ class Projects::CompareController < Projects::ApplicationController end def show - compare = Gitlab::Git::Compare.new(@repository.raw_repository, params[:from], params[:to]) + compare = Gitlab::Git::Compare.new(@repository.raw_repository, params[:from], params[:to], MergeRequestDiff::COMMITS_SAFE_SIZE) @commits = compare.commits @commit = compare.commit diff --git a/app/views/projects/compare/_form.html.haml b/app/views/projects/compare/_form.html.haml index 0762655fb9..da6157cf1b 100644 --- a/app/views/projects/compare/_form.html.haml +++ b/app/views/projects/compare/_form.html.haml @@ -14,7 +14,7 @@   = submit_tag "Compare", class: "btn btn-create commits-compare-btn" - if compare_to_mr_button? - = link_to compare_mr_path, class: 'prepend-left-10' do + = link_to compare_mr_path, class: 'prepend-left-10 btn' do %strong Make a merge request diff --git a/app/views/projects/compare/show.html.haml b/app/views/projects/compare/show.html.haml index 6b0b12a3ee..e0c1b01dfb 100644 --- a/app/views/projects/compare/show.html.haml +++ b/app/views/projects/compare/show.html.haml @@ -5,12 +5,6 @@ = render "form" -- if @commits.size > 100 - .alert.alert-warning - %p - %strong Warning! This comparison includes more than 100 commits. - %p To preserve performance the line diff is not shown. - - if @commits.present? %div.ui-box .title @@ -24,9 +18,15 @@ - else %ul.well-list= render Commit.decorate(@commits), project: @project - - unless @diffs.empty? - %h4 Diff + %h4 Diff + - if @diffs.present? = render "projects/commits/diffs", diffs: @diffs, project: @project + - elsif @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE + .alert.alert-warning + %p + %strong Warning! This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits. + %p To preserve performance the line diff is not shown. + - else .light-well %center From a1a01254b903d76e0151b48fa4316add9a6930da Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 5 Feb 2014 16:21:41 +0200 Subject: [PATCH 3/3] Prevent 500 error on Compare page if diff read timout happens Signed-off-by: Dmitriy Zaporozhets --- app/controllers/projects/compare_controller.rb | 5 +++++ app/views/projects/compare/show.html.haml | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb index 02fcb8d255..696cb7a4ba 100644 --- a/app/controllers/projects/compare_controller.rb +++ b/app/controllers/projects/compare_controller.rb @@ -16,6 +16,11 @@ class Projects::CompareController < Projects::ApplicationController @refs_are_same = compare.same @line_notes = [] + if @diffs == [Gitlab::Git::Diff::BROKEN_DIFF] + @diffs = [] + @timeout = true + end + diff_line_count = Commit::diff_line_count(@diffs) @suppress_diff = Commit::diff_suppress?(@diffs, diff_line_count) && !params[:force_show_diff] @force_suppress_diff = Commit::diff_force_suppress?(@diffs, diff_line_count) diff --git a/app/views/projects/compare/show.html.haml b/app/views/projects/compare/show.html.haml index e0c1b01dfb..9bd4985536 100644 --- a/app/views/projects/compare/show.html.haml +++ b/app/views/projects/compare/show.html.haml @@ -22,10 +22,14 @@ - if @diffs.present? = render "projects/commits/diffs", diffs: @diffs, project: @project - elsif @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE - .alert.alert-warning - %p - %strong Warning! This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits. + .bs-callout.bs-callout-danger + %h4 This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits. %p To preserve performance the line diff is not shown. + - elsif @timeout + .bs-callout.bs-callout-danger + %h4 Diff for this comparison is extremely large. + %p Use command line to browse diff for this comparison. + - else .light-well