diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 3cec2e8e..a90b57c3 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -88,7 +88,7 @@ class RepositoriesController < ApplicationController def changes @entry = @repository.entry(@path, @rev) show_error_not_found and return unless @entry - @changesets = @repository.changesets_for_path(@path) + @changesets = @repository.changesets_for_path(@path, :limit => Setting.repository_log_display_limit.to_i) @properties = @repository.properties(@path, @rev) end diff --git a/app/models/repository.rb b/app/models/repository.rb index 003f3055..920cf246 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -76,11 +76,12 @@ class Repository < ActiveRecord::Base end # Default behaviour: we search in cached changesets - def changesets_for_path(path) + def changesets_for_path(path, options={}) path = "/#{path}" unless path.starts_with?('/') Change.find(:all, :include => {:changeset => :user}, - :conditions => ["repository_id = ? AND path = ?", id, path], - :order => "committed_on DESC, #{Changeset.table_name}.id DESC").collect(&:changeset) + :conditions => ["repository_id = ? AND path = ?", id, path], + :order => "committed_on DESC, #{Changeset.table_name}.id DESC", + :limit => options[:limit]).collect(&:changeset) end # Returns a path relative to the url of the repository diff --git a/app/models/repository/git.rb b/app/models/repository/git.rb index 41d4b649..f721b938 100644 --- a/app/models/repository/git.rb +++ b/app/models/repository/git.rb @@ -29,10 +29,11 @@ class Repository::Git < Repository 'Git' end - def changesets_for_path(path) + def changesets_for_path(path, options={}) Change.find(:all, :include => {:changeset => :user}, :conditions => ["repository_id = ? AND path = ?", id, path], - :order => "committed_on DESC, #{Changeset.table_name}.revision DESC").collect(&:changeset) + :order => "committed_on DESC, #{Changeset.table_name}.revision DESC", + :limit => options[:limit]).collect(&:changeset) end def fetch_changesets diff --git a/app/models/repository/subversion.rb b/app/models/repository/subversion.rb index 9515e6b7..a7458970 100644 --- a/app/models/repository/subversion.rb +++ b/app/models/repository/subversion.rb @@ -30,8 +30,8 @@ class Repository::Subversion < Repository 'Subversion' end - def changesets_for_path(path) - revisions = scm.revisions(path) + def changesets_for_path(path, options={}) + revisions = scm.revisions(path, nil, nil, :limit => options[:limit]) revisions ? changesets.find_all_by_revision(revisions.collect(&:identifier), :order => "committed_on DESC", :include => :user) : [] end diff --git a/app/views/settings/_repositories.rhtml b/app/views/settings/_repositories.rhtml index a8c92443..a20fc513 100644 --- a/app/views/settings/_repositories.rhtml +++ b/app/views/settings/_repositories.rhtml @@ -19,6 +19,9 @@

<%= select_tag 'settings[commit_logs_encoding]', options_for_select(Setting::ENCODINGS, Setting.commit_logs_encoding) %>

+ +

+<%= text_field_tag 'settings[repository_log_display_limit]', Setting.repository_log_display_limit, :size => 6 %>

<%= l(:text_issues_ref_in_commit_messages) %> diff --git a/config/settings.yml b/config/settings.yml index 50064450..1aba0644 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -132,6 +132,9 @@ repositories_encodings: # encoding used to convert commit logs to UTF-8 commit_logs_encoding: default: 'UTF-8' +repository_log_display_limit: + format: int + default: 100 ui_theme: default: '' emails_footer: diff --git a/lang/bg.yml b/lang/bg.yml index bb80f170..501b4c7a 100644 --- a/lang/bg.yml +++ b/lang/bg.yml @@ -702,3 +702,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/ca.yml b/lang/ca.yml index b0bbee2e..216303e2 100644 --- a/lang/ca.yml +++ b/lang/ca.yml @@ -703,3 +703,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/cs.yml b/lang/cs.yml index ab062486..19843331 100644 --- a/lang/cs.yml +++ b/lang/cs.yml @@ -707,3 +707,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/da.yml b/lang/da.yml index aee6b140..cd8fe5f0 100644 --- a/lang/da.yml +++ b/lang/da.yml @@ -704,3 +704,4 @@ text_repository_usernames_mapping: "Select or update the Redmine user mapped to permission_edit_time_entries: Edit time logs general_csv_decimal_separator: '.' permission_edit_own_time_entries: Edit own time logs +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/de.yml b/lang/de.yml index a80b729d..19dbfd75 100644 --- a/lang/de.yml +++ b/lang/de.yml @@ -705,3 +705,4 @@ field_editable: Editable label_display: Display button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/en.yml b/lang/en.yml index 36e45469..246bfb13 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -227,6 +227,7 @@ setting_mail_handler_api_key: API key setting_sequential_project_identifiers: Generate sequential project identifiers setting_gravatar_enabled: Use Gravatar user icons setting_diff_max_lines_displayed: Max number of diff lines displayed +setting_repository_log_display_limit: Maximum number of revisions displayed on file log permission_edit_project: Edit project permission_select_project_modules: Select project modules diff --git a/lang/es.yml b/lang/es.yml index c6e6234e..75f5391b 100644 --- a/lang/es.yml +++ b/lang/es.yml @@ -687,3 +687,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/fi.yml b/lang/fi.yml index dce1192e..9b82e2c6 100644 --- a/lang/fi.yml +++ b/lang/fi.yml @@ -702,3 +702,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/fr.yml b/lang/fr.yml index 84f18e83..5e9cff85 100644 --- a/lang/fr.yml +++ b/lang/fr.yml @@ -227,6 +227,7 @@ setting_mail_handler_api_key: Clé de protection de l'API setting_sequential_project_identifiers: Générer des identifiants de projet séquentiels setting_gravatar_enabled: Afficher les Gravatar des utilisateurs setting_diff_max_lines_displayed: Nombre maximum de lignes de diff affichées +setting_repository_log_display_limit: "Nombre maximum de revisions affichées sur l'historique d'un fichier" permission_edit_project: Modifier le projet permission_select_project_modules: Choisir les modules diff --git a/lang/gl.yml b/lang/gl.yml index b69a274b..5363a7ad 100644 --- a/lang/gl.yml +++ b/lang/gl.yml @@ -687,3 +687,4 @@ text_plugin_assets_writable: Plugin assets directory writable label_display: Display button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/he.yml b/lang/he.yml index 2fae88e8..a2e4148f 100644 --- a/lang/he.yml +++ b/lang/he.yml @@ -702,3 +702,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/hu.yml b/lang/hu.yml index 454b8e98..223b79b4 100644 --- a/lang/hu.yml +++ b/lang/hu.yml @@ -703,3 +703,4 @@ button_create_and_continue: Létrehozás és folytatás text_custom_field_possible_values_info: 'Értékenként egy sor' label_display: Megmutat field_editable: Szerkeszthető +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/it.yml b/lang/it.yml index 7883942c..0e87fdb8 100644 --- a/lang/it.yml +++ b/lang/it.yml @@ -702,3 +702,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/ja.yml b/lang/ja.yml index a8b33c3e..e6a38d17 100644 --- a/lang/ja.yml +++ b/lang/ja.yml @@ -703,3 +703,4 @@ button_create_and_continue: 連続作成 text_custom_field_possible_values_info: '選択肢の値は1行に1個ずつ記述してください。' label_display: 表示 field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/ko.yml b/lang/ko.yml index 8da9ac6d..5afce6d3 100644 --- a/lang/ko.yml +++ b/lang/ko.yml @@ -702,3 +702,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/lt.yml b/lang/lt.yml index 9bd57f8c..6b7422a0 100644 --- a/lang/lt.yml +++ b/lang/lt.yml @@ -704,3 +704,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/nl.yml b/lang/nl.yml index 882901db..6a07bc42 100644 --- a/lang/nl.yml +++ b/lang/nl.yml @@ -687,3 +687,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/no.yml b/lang/no.yml index 0e848772..b7c471be 100644 --- a/lang/no.yml +++ b/lang/no.yml @@ -703,3 +703,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/pl.yml b/lang/pl.yml index 5fdf9ebc..3f06d7d8 100644 --- a/lang/pl.yml +++ b/lang/pl.yml @@ -721,3 +721,4 @@ field_editable: Editable label_display: Display button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/pt-br.yml b/lang/pt-br.yml index 748f118c..eb015a44 100644 --- a/lang/pt-br.yml +++ b/lang/pt-br.yml @@ -703,3 +703,4 @@ button_create_and_continue: Criar e continuar text_custom_field_possible_values_info: 'Uma linha para cada valor' label_display: Exibição field_editable: Editável +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/pt.yml b/lang/pt.yml index 980a6e5e..c1e604ff 100644 --- a/lang/pt.yml +++ b/lang/pt.yml @@ -704,3 +704,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/ro.yml b/lang/ro.yml index bf1f1176..6ffd394f 100644 --- a/lang/ro.yml +++ b/lang/ro.yml @@ -702,3 +702,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/ru.yml b/lang/ru.yml index 2e8f0f10..506c94cc 100644 --- a/lang/ru.yml +++ b/lang/ru.yml @@ -737,3 +737,4 @@ text_custom_field_possible_values_info: 'По одному значению в label_display: Отображение field_editable: Редактируемый +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/sk.yml b/lang/sk.yml index b5c2ee2d..4c0b12db 100644 --- a/lang/sk.yml +++ b/lang/sk.yml @@ -707,3 +707,4 @@ field_editable: Editable label_display: Display button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/sl.yml b/lang/sl.yml index fe41e111..ba719f59 100644 --- a/lang/sl.yml +++ b/lang/sl.yml @@ -704,3 +704,4 @@ text_plugin_assets_writable: Plugin assets directory writable label_display: Display button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/sr.yml b/lang/sr.yml index 455173d0..95b27bc2 100644 --- a/lang/sr.yml +++ b/lang/sr.yml @@ -703,3 +703,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/sv.yml b/lang/sv.yml index 601bd529..3d450429 100644 --- a/lang/sv.yml +++ b/lang/sv.yml @@ -703,4 +703,5 @@ default_activity_development: Utveckling enumeration_issue_priorities: Ärendeprioriteter enumeration_doc_categories: Dokumentkategorier -enumeration_activities: Aktiviteter (tidsuppföljning +enumeration_activities: Aktiviteter (tidsuppföljning) +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/th.yml b/lang/th.yml index 8d39fb5d..7eb90d09 100644 --- a/lang/th.yml +++ b/lang/th.yml @@ -705,3 +705,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/tr.yml b/lang/tr.yml index 80655926..2b66ec0d 100644 --- a/lang/tr.yml +++ b/lang/tr.yml @@ -703,3 +703,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/uk.yml b/lang/uk.yml index 75c6639c..16ca88c3 100644 --- a/lang/uk.yml +++ b/lang/uk.yml @@ -704,3 +704,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/vn.yml b/lang/vn.yml index 0bff54b5..1aa01695 100644 --- a/lang/vn.yml +++ b/lang/vn.yml @@ -705,3 +705,4 @@ button_create_and_continue: Create and continue text_custom_field_possible_values_info: 'One line for each value' label_display: Display field_editable: Editable +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/zh-tw.yml b/lang/zh-tw.yml index e92ce806..5d75e833 100644 --- a/lang/zh-tw.yml +++ b/lang/zh-tw.yml @@ -705,3 +705,4 @@ default_activity_development: 開發 enumeration_issue_priorities: 項目優先權 enumeration_doc_categories: 文件分類 enumeration_activities: 活動 (時間追蹤) +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lang/zh.yml b/lang/zh.yml index 2232ef62..bb1b8896 100644 --- a/lang/zh.yml +++ b/lang/zh.yml @@ -705,3 +705,4 @@ default_activity_development: 开发 enumeration_issue_priorities: 问题优先级 enumeration_doc_categories: 文档类别 enumeration_activities: 活动(时间跟踪) +setting_repository_log_display_limit: Maximum number of revisions displayed on file log diff --git a/lib/redmine/scm/adapters/subversion_adapter.rb b/lib/redmine/scm/adapters/subversion_adapter.rb index 0a96ed65..61cce93b 100644 --- a/lib/redmine/scm/adapters/subversion_adapter.rb +++ b/lib/redmine/scm/adapters/subversion_adapter.rb @@ -141,6 +141,7 @@ module Redmine cmd = "#{SVN_BIN} log --xml -r #{identifier_from}:#{identifier_to}" cmd << credentials_string cmd << " --verbose " if options[:with_paths] + cmd << " --limit #{options[:limit].to_i}" if options[:limit] cmd << ' ' + target(URI.escape(path)) shellout(cmd) do |io| begin diff --git a/test/unit/repository_subversion_test.rb b/test/unit/repository_subversion_test.rb index 7a1c9df4..4054a0e4 100644 --- a/test/unit/repository_subversion_test.rb +++ b/test/unit/repository_subversion_test.rb @@ -48,6 +48,13 @@ class RepositorySubversionTest < Test::Unit::TestCase @repository.fetch_changesets assert_equal 8, @repository.changesets.count end + + def test_changesets_for_path_with_limit + @repository.fetch_changesets + changesets = @repository.changesets_for_path('', :limit => 2) + assert_equal 2, changesets.size + assert_equal @repository.changesets_for_path('').slice(0,2), changesets + end else puts "Subversion test repository NOT FOUND. Skipping unit tests !!!" def test_fake; assert true end