show_error and return unless @entry
end
@repository.changesets_with_path @path do
- @changeset_count = @repository.changesets.count
+ @changeset_count = @repository.changesets.count(:select => "DISTINCT #{Changeset.table_name}.id")
@changeset_pages = Paginator.new self, @changeset_count,
25,
params['page']
def revision
@changeset = @repository.changesets.find_by_revision(@rev)
show_error and return unless @changeset
+ @changes_count = @changeset.changes.size
+ @changes_pages = Paginator.new self, @changes_count, 150, params['page']
+ @changes = @changeset.changes.find(:all,
+ :limit => @changes_pages.items_per_page,
+ :offset => @changes_pages.current.offset)
+
+ render :action => "revision", :layout => false if request.xhr?
end
def diff
path = "/#{path}%"
path = url.gsub(/^#{root_url}/, '') + path if root_url && root_url != url
path.squeeze!("/")
- Changeset.with_scope(:find => { :include => :changes, :conditions => ["#{Change.table_name}.path LIKE ?", path] }) do
+ # Custom select and joins is done to allow conditions on changes table without loading associated Change objects
+ # Required for changesets with a great number of changes (eg. 100,000)
+ Changeset.with_scope(:find => { :select => "DISTINCT #{Changeset.table_name}.*", :joins => "LEFT OUTER JOIN #{Change.table_name} ON #{Change.table_name}.changeset_id = #{Changeset.table_name}.id", :conditions => ["#{Change.table_name}.path LIKE ?", path] }) do
yield
end
end
<p><%= link_to(l(:label_view_diff), :action => 'diff', :id => @project, :path => "", :rev => @changeset.revision) if @changeset.changes.any? %></p>
<table class="list">
<tbody>
-<% @changeset.changes.each do |change| %>
+<% @changes.each do |change| %>
<tr class="<%= cycle 'odd', 'even' %>">
<td><div class="square action_<%= change.action %>"></div> <%= change.path %></td>
<td align="right">
<% end %>
</tbody>
</table>
-<p><%= lwr(:label_modification, @changeset.changes.length) %></p>
+<p><%= pagination_links_full @changes_pages, :rev => @changeset.revision %>
+[ <%= @changes_pages.current.first_item %> - <%= @changes_pages.current.last_item %> / <%= @changes_count %> ]</p>
<% content_for :header_tags do %>
<%= stylesheet_link_tag "scm" %>
-<% end %>
\ No newline at end of file
+<% end %>
--- /dev/null
+--- \r
+changes_001: \r
+ id: 1\r
+ changeset_id: 100\r
+ action: A\r
+ path: /test/some/path/in/the/repo\r
+ from_path:\r
+ from_revision:\r
+changes_002: \r
+ id: 2\r
+ changeset_id: 100\r
+ action: A\r
+ path: /test/some/path/elsewhere/in/the/repo\r
+ from_path:\r
+ from_revision:\r
+
\ No newline at end of file
require File.dirname(__FILE__) + '/../test_helper'
class RepositoryTest < Test::Unit::TestCase
- fixtures :projects, :repositories, :issues, :issue_statuses, :changesets
+ fixtures :projects, :repositories, :issues, :issue_statuses, :changesets, :changes
+
+ def setup
+ @repository = Project.find(1).repository
+ end
\r
def test_create\r
repository = Repository.new(:project => Project.find(2))
end\r
def test_cant_change_url
- repository = Project.find(1).repository
- url = repository.url
- repository.url = "svn://anotherhost"
- assert_equal url, repository.url
+ url = @repository.url
+ @repository.url = "svn://anotherhost"
+ assert_equal url, @repository.url
end
def test_scan_changesets_for_issue_ids
# ignoring commits referencing an issue of another project
assert_equal [], Issue.find(4).changesets
end
+
+ def test_changesets_with_path
+ @repository.changesets_with_path '/some/path' do
+ assert_equal 1, @repository.changesets.count(:select => "DISTINCT #{Changeset.table_name}.id")
+ changesets = @repository.changesets.find(:all)
+ assert_equal 1, changesets.size
+ end
+ end
end