From 9ce5713ee49166a826fcd4355aab825070ddfa07 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 15 Oct 2007 18:41:27 +0000 Subject: [PATCH] Fixed: log is not displayed when browsing a copy in a svn repository. git-svn-id: http://redmine.rubyforge.org/svn/trunk@843 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/repositories_controller.rb | 4 +--- app/models/repository.rb | 8 ++++++++ app/models/repository/subversion.rb | 5 +++++ app/views/repositories/_revisions.rhtml | 5 ++--- app/views/repositories/changes.rhtml | 2 +- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 12439cfab..9439481e2 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -62,9 +62,7 @@ class RepositoriesController < ApplicationController def changes @entry = @repository.scm.entry(@path, @rev) show_error and return unless @entry - @changes = Change.find(:all, :include => :changeset, - :conditions => ["repository_id = ? AND path = ?", @repository.id, @path.with_leading_slash], - :order => "committed_on DESC") + @changesets = @repository.changesets_for_path(@path) end def revisions diff --git a/app/models/repository.rb b/app/models/repository.rb index f77b51db2..35dd6803f 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -42,6 +42,14 @@ class Repository < ActiveRecord::Base scm.diff(path, rev, rev_to, type) end + # Default behaviour: we search in cached changesets + def changesets_for_path(path) + path = "/#{path}" unless path.starts_with?('/') + Change.find(:all, :include => :changeset, + :conditions => ["repository_id = ? AND path = ?", id, path], + :order => "committed_on DESC, #{Changeset.table_name}.revision DESC").collect(&:changeset) + end + def latest_changeset @latest_changeset ||= changesets.find(:first) end diff --git a/app/models/repository/subversion.rb b/app/models/repository/subversion.rb index 2f0990b2e..a0485608d 100644 --- a/app/models/repository/subversion.rb +++ b/app/models/repository/subversion.rb @@ -30,6 +30,11 @@ class Repository::Subversion < Repository 'Subversion' end + def changesets_for_path(path) + revisions = scm.revisions(path) + revisions ? changesets.find_all_by_revision(revisions.collect(&:identifier), :order => "committed_on DESC") : [] + end + def fetch_changesets scm_info = scm.info if scm_info diff --git a/app/views/repositories/_revisions.rhtml b/app/views/repositories/_revisions.rhtml index 06b1cbd49..1cdc45a35 100644 --- a/app/views/repositories/_revisions.rhtml +++ b/app/views/repositories/_revisions.rhtml @@ -11,10 +11,9 @@ <% show_diff = entry && entry.is_file? && revisions.size > 1 %> <% line_num = 1 %> -<% revisions.each do |revision| %> -<% changeset = revision.is_a?(Change) ? revision.changeset : revision %> +<% revisions.each do |changeset| %> -<%= link_to (revision.revision || changeset.revision), :action => 'revision', :id => project, :rev => changeset.revision %> +<%= link_to changeset.revision, :action => 'revision', :id => project, :rev => changeset.revision %> <%= radio_button_tag('rev', changeset.revision, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('cbto-#{line_num+1}').checked=true;") if show_diff && (line_num < revisions.size) %> <%= radio_button_tag('rev_to', changeset.revision, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('cb-#{line_num}').checked==true) {$('cb-#{line_num-1}').checked=true;}") if show_diff && (line_num > 1) %> <%= format_time(changeset.committed_on) %> diff --git a/app/views/repositories/changes.rhtml b/app/views/repositories/changes.rhtml index b8610818b..5d1db96ba 100644 --- a/app/views/repositories/changes.rhtml +++ b/app/views/repositories/changes.rhtml @@ -12,4 +12,4 @@

<% end %> -<%= render :partial => 'revisions', :locals => {:project => @project, :path => @path, :revisions => @changes, :entry => @entry }%> +<%= render :partial => 'revisions', :locals => {:project => @project, :path => @path, :revisions => @changesets, :entry => @entry }%> -- 2.39.5