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| %>