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
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
'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
<tbody>
<% 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| %>
<tr class="<%= cycle 'odd', 'even' %>">
-<td class="id"><%= link_to (revision.revision || changeset.revision), :action => 'revision', :id => project, :rev => changeset.revision %></th>
+<td class="id"><%= link_to changeset.revision, :action => 'revision', :id => project, :rev => changeset.revision %></th>
<td class="checkbox"><%= 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) %></td>
<td class="checkbox"><%= 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) %></td>
<td align="center" style="width:15%"><%= format_time(changeset.committed_on) %></td>
</p>
<% 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 }%>