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
This commit is contained in:
Jean-Philippe Lang 2009-02-01 19:54:50 +00:00
parent d3b2049851
commit ab5e07e83e
41 changed files with 58 additions and 9 deletions

View File

@ -88,7 +88,7 @@ class RepositoriesController < ApplicationController
def changes def changes
@entry = @repository.entry(@path, @rev) @entry = @repository.entry(@path, @rev)
show_error_not_found and return unless @entry 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) @properties = @repository.properties(@path, @rev)
end end

View File

@ -76,11 +76,12 @@ class Repository < ActiveRecord::Base
end end
# Default behaviour: we search in cached changesets # Default behaviour: we search in cached changesets
def changesets_for_path(path) def changesets_for_path(path, options={})
path = "/#{path}" unless path.starts_with?('/') path = "/#{path}" unless path.starts_with?('/')
Change.find(:all, :include => {:changeset => :user}, Change.find(:all, :include => {:changeset => :user},
:conditions => ["repository_id = ? AND path = ?", id, path], :conditions => ["repository_id = ? AND path = ?", id, path],
:order => "committed_on DESC, #{Changeset.table_name}.id DESC").collect(&:changeset) :order => "committed_on DESC, #{Changeset.table_name}.id DESC",
:limit => options[:limit]).collect(&:changeset)
end end
# Returns a path relative to the url of the repository # Returns a path relative to the url of the repository

View File

@ -29,10 +29,11 @@ class Repository::Git < Repository
'Git' 'Git'
end end
def changesets_for_path(path) def changesets_for_path(path, options={})
Change.find(:all, :include => {:changeset => :user}, Change.find(:all, :include => {:changeset => :user},
:conditions => ["repository_id = ? AND path = ?", id, path], :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 end
def fetch_changesets def fetch_changesets

View File

@ -30,8 +30,8 @@ class Repository::Subversion < Repository
'Subversion' 'Subversion'
end end
def changesets_for_path(path) def changesets_for_path(path, options={})
revisions = scm.revisions(path) revisions = scm.revisions(path, nil, nil, :limit => options[:limit])
revisions ? changesets.find_all_by_revision(revisions.collect(&:identifier), :order => "committed_on DESC", :include => :user) : [] revisions ? changesets.find_all_by_revision(revisions.collect(&:identifier), :order => "committed_on DESC", :include => :user) : []
end end

View File

@ -19,6 +19,9 @@
<p><label><%= l(:setting_commit_logs_encoding) %></label> <p><label><%= l(:setting_commit_logs_encoding) %></label>
<%= select_tag 'settings[commit_logs_encoding]', options_for_select(Setting::ENCODINGS, Setting.commit_logs_encoding) %></p> <%= select_tag 'settings[commit_logs_encoding]', options_for_select(Setting::ENCODINGS, Setting.commit_logs_encoding) %></p>
<p><label><%= l(:setting_repository_log_display_limit) %></label>
<%= text_field_tag 'settings[repository_log_display_limit]', Setting.repository_log_display_limit, :size => 6 %></p>
</div> </div>
<fieldset class="box tabular settings"><legend><%= l(:text_issues_ref_in_commit_messages) %></legend> <fieldset class="box tabular settings"><legend><%= l(:text_issues_ref_in_commit_messages) %></legend>

View File

@ -132,6 +132,9 @@ repositories_encodings:
# encoding used to convert commit logs to UTF-8 # encoding used to convert commit logs to UTF-8
commit_logs_encoding: commit_logs_encoding:
default: 'UTF-8' default: 'UTF-8'
repository_log_display_limit:
format: int
default: 100
ui_theme: ui_theme:
default: '' default: ''
emails_footer: emails_footer:

View File

@ -702,3 +702,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -703,3 +703,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -707,3 +707,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -704,3 +704,4 @@ text_repository_usernames_mapping: "Select or update the Redmine user mapped to
permission_edit_time_entries: Edit time logs permission_edit_time_entries: Edit time logs
general_csv_decimal_separator: '.' general_csv_decimal_separator: '.'
permission_edit_own_time_entries: Edit own time logs permission_edit_own_time_entries: Edit own time logs
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -705,3 +705,4 @@ field_editable: Editable
label_display: Display label_display: Display
button_create_and_continue: Create and continue button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -227,6 +227,7 @@ setting_mail_handler_api_key: API key
setting_sequential_project_identifiers: Generate sequential project identifiers setting_sequential_project_identifiers: Generate sequential project identifiers
setting_gravatar_enabled: Use Gravatar user icons setting_gravatar_enabled: Use Gravatar user icons
setting_diff_max_lines_displayed: Max number of diff lines displayed 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_edit_project: Edit project
permission_select_project_modules: Select project modules permission_select_project_modules: Select project modules

View File

@ -687,3 +687,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -702,3 +702,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -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_sequential_project_identifiers: Générer des identifiants de projet séquentiels
setting_gravatar_enabled: Afficher les Gravatar des utilisateurs setting_gravatar_enabled: Afficher les Gravatar des utilisateurs
setting_diff_max_lines_displayed: Nombre maximum de lignes de diff affichées 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_edit_project: Modifier le projet
permission_select_project_modules: Choisir les modules permission_select_project_modules: Choisir les modules

View File

@ -687,3 +687,4 @@ text_plugin_assets_writable: Plugin assets directory writable
label_display: Display label_display: Display
button_create_and_continue: Create and continue button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -702,3 +702,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -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' text_custom_field_possible_values_info: 'Értékenként egy sor'
label_display: Megmutat label_display: Megmutat
field_editable: Szerkeszthető field_editable: Szerkeszthető
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -702,3 +702,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -703,3 +703,4 @@ button_create_and_continue: 連続作成
text_custom_field_possible_values_info: '選択肢の値は1行に1個ずつ記述してください。' text_custom_field_possible_values_info: '選択肢の値は1行に1個ずつ記述してください。'
label_display: 表示 label_display: 表示
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -702,3 +702,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -704,3 +704,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -687,3 +687,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -703,3 +703,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -721,3 +721,4 @@ field_editable: Editable
label_display: Display label_display: Display
button_create_and_continue: Create and continue button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -703,3 +703,4 @@ button_create_and_continue: Criar e continuar
text_custom_field_possible_values_info: 'Uma linha para cada valor' text_custom_field_possible_values_info: 'Uma linha para cada valor'
label_display: Exibição label_display: Exibição
field_editable: Editável field_editable: Editável
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -704,3 +704,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -702,3 +702,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -737,3 +737,4 @@ text_custom_field_possible_values_info: 'По одному значению в
label_display: Отображение label_display: Отображение
field_editable: Редактируемый field_editable: Редактируемый
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -707,3 +707,4 @@ field_editable: Editable
label_display: Display label_display: Display
button_create_and_continue: Create and continue button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -704,3 +704,4 @@ text_plugin_assets_writable: Plugin assets directory writable
label_display: Display label_display: Display
button_create_and_continue: Create and continue button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -703,3 +703,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -703,4 +703,5 @@ default_activity_development: Utveckling
enumeration_issue_priorities: Ärendeprioriteter enumeration_issue_priorities: Ärendeprioriteter
enumeration_doc_categories: Dokumentkategorier 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

View File

@ -705,3 +705,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -703,3 +703,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -704,3 +704,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -705,3 +705,4 @@ button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value' text_custom_field_possible_values_info: 'One line for each value'
label_display: Display label_display: Display
field_editable: Editable field_editable: Editable
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -705,3 +705,4 @@ default_activity_development: 開發
enumeration_issue_priorities: 項目優先權 enumeration_issue_priorities: 項目優先權
enumeration_doc_categories: 文件分類 enumeration_doc_categories: 文件分類
enumeration_activities: 活動 (時間追蹤) enumeration_activities: 活動 (時間追蹤)
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -705,3 +705,4 @@ default_activity_development: 开发
enumeration_issue_priorities: 问题优先级 enumeration_issue_priorities: 问题优先级
enumeration_doc_categories: 文档类别 enumeration_doc_categories: 文档类别
enumeration_activities: 活动(时间跟踪) enumeration_activities: 活动(时间跟踪)
setting_repository_log_display_limit: Maximum number of revisions displayed on file log

View File

@ -141,6 +141,7 @@ module Redmine
cmd = "#{SVN_BIN} log --xml -r #{identifier_from}:#{identifier_to}" cmd = "#{SVN_BIN} log --xml -r #{identifier_from}:#{identifier_to}"
cmd << credentials_string cmd << credentials_string
cmd << " --verbose " if options[:with_paths] cmd << " --verbose " if options[:with_paths]
cmd << " --limit #{options[:limit].to_i}" if options[:limit]
cmd << ' ' + target(URI.escape(path)) cmd << ' ' + target(URI.escape(path))
shellout(cmd) do |io| shellout(cmd) do |io|
begin begin

View File

@ -48,6 +48,13 @@ class RepositorySubversionTest < Test::Unit::TestCase
@repository.fetch_changesets @repository.fetch_changesets
assert_equal 8, @repository.changesets.count assert_equal 8, @repository.changesets.count
end 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 else
puts "Subversion test repository NOT FOUND. Skipping unit tests !!!" puts "Subversion test repository NOT FOUND. Skipping unit tests !!!"
def test_fake; assert true end def test_fake; assert true end