From ab5e07e83ef2573ae32da1a7ada5398d03777932 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 1 Feb 2009 19:54:50 +0000 Subject: [PATCH] Adds a setting to limit the number of revisions displayed on a repository file log (default=100). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2350 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/repositories_controller.rb | 2 +- app/models/repository.rb | 7 ++++--- app/models/repository/git.rb | 5 +++-- app/models/repository/subversion.rb | 4 ++-- app/views/settings/_repositories.rhtml | 3 +++ config/settings.yml | 3 +++ lang/bg.yml | 1 + lang/ca.yml | 1 + lang/cs.yml | 1 + lang/da.yml | 1 + lang/de.yml | 1 + lang/en.yml | 1 + lang/es.yml | 1 + lang/fi.yml | 1 + lang/fr.yml | 1 + lang/gl.yml | 1 + lang/he.yml | 1 + lang/hu.yml | 1 + lang/it.yml | 1 + lang/ja.yml | 1 + lang/ko.yml | 1 + lang/lt.yml | 1 + lang/nl.yml | 1 + lang/no.yml | 1 + lang/pl.yml | 1 + lang/pt-br.yml | 1 + lang/pt.yml | 1 + lang/ro.yml | 1 + lang/ru.yml | 1 + lang/sk.yml | 1 + lang/sl.yml | 1 + lang/sr.yml | 1 + lang/sv.yml | 3 ++- lang/th.yml | 1 + lang/tr.yml | 1 + lang/uk.yml | 1 + lang/vn.yml | 1 + lang/zh-tw.yml | 1 + lang/zh.yml | 1 + lib/redmine/scm/adapters/subversion_adapter.rb | 1 + test/unit/repository_subversion_test.rb | 7 +++++++ 41 files changed, 58 insertions(+), 9 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 3cec2e8e5..a90b57c3d 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 003f30552..920cf2460 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 41d4b6498..f721b938f 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 9515e6b76..a74589705 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 a8c924430..a20fc5131 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 50064450f..1aba06441 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 bb80f1708..501b4c7a8 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 b0bbee2eb..216303e2e 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 ab0624860..198433315 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 aee6b140c..cd8fe5f01 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 a80b729d4..19dbfd758 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 36e454692..246bfb13e 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 c6e6234e8..75f5391bf 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 dce1192ea..9b82e2c61 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 84f18e839..5e9cff85b 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 b69a274b5..5363a7adf 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 2fae88e80..a2e4148f4 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 454b8e986..223b79b40 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 7883942c3..0e87fdb87 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 a8b33c3ee..e6a38d172 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 8da9ac6d0..5afce6d3e 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 9bd57f8c6..6b7422a0b 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 882901db6..6a07bc421 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 0e848772e..b7c471be0 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 5fdf9ebcc..3f06d7d83 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 748f118c7..eb015a447 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 980a6e5e0..c1e604ffe 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 bf1f11769..6ffd394f7 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 2e8f0f105..506c94cc8 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 b5c2ee2d9..4c0b12dbe 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 fe41e111c..ba719f59e 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 455173d0c..95b27bc20 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 601bd5295..3d450429d 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 8d39fb5db..7eb90d09a 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 80655926f..2b66ec0dc 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 75c6639cb..16ca88c39 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 0bff54b57..1aa016951 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 e92ce806d..5d75e8336 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 2232ef621..bb1b88961 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 0a96ed654..61cce93b0 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 7a1c9df4a..4054a0e41 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