Index: app/controllers/repositories_controller.rb =================================================================== --- app/controllers/repositories_controller.rb (revision 4794) +++ app/controllers/repositories_controller.rb (working copy) @@ -96,6 +96,17 @@ @properties = @repository.properties(@path, @rev) end + + # fetch the next set of 200 revisions from the repo. + def fetch_revisions + oldest = @repository.earliest_revision + if oldest > 0 + @repository.fetch_older_changesets(oldest, 200) + redirect_to :action => 'show', :id => @project + end + end + + def revisions @changeset_count = @repository.changesets.count @changeset_pages = Paginator.new self, @changeset_count, Index: app/models/repository/subversion.rb =================================================================== --- app/models/repository/subversion.rb (revision 4794) +++ app/models/repository/subversion.rb (working copy) @@ -40,13 +40,44 @@ path.gsub(Regexp.new("^\/?#{Regexp.escape(relative_url)}"), '') end + + + # we store only the most current 200 revs at first, but each time we call this + # we want to fetch another 200 to add to the history + # oldest - earliest rev stored in the db + def fetch_older_changesets(oldest, num_to_fetch) + if oldest > 0 + identifier_from = oldest - 1 + # load next set of older revisions + identifier_to = [identifier_from - num_to_fetch, 0].max + revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true) + revisions.reverse_each do |revision| + transaction do + changeset = Changeset.create(:repository => self, + :revision => revision.identifier, + :committer => revision.author, + :committed_on => revision.time, + :comments => revision.message) + + revision.paths.each do |change| + changeset.create_change(change) + end unless changeset.new_record? + end + end unless revisions.nil? + # save the new earliest revision number, or 0 if we've got them all. + self.earliest_revision = identifier_to + self.save + end + end + + def fetch_changesets scm_info = scm.info if scm_info - # latest revision found in database - db_revision = latest_changeset ? latest_changeset.revision.to_i : 0 # latest revision in the repository scm_revision = scm_info.lastrev.identifier.to_i + # latest revision found in database + db_revision = latest_changeset ? latest_changeset.revision.to_i : [scm_revision - 199, 0].max if db_revision < scm_revision logger.debug "Fetching changesets for repository #{url}" if logger && logger.debug? identifier_from = db_revision + 1 Index: app/views/repositories/revisions.rhtml =================================================================== --- app/views/repositories/revisions.rhtml (revision 4794) +++ app/views/repositories/revisions.rhtml (working copy) @@ -11,6 +11,10 @@

<%= pagination_links_full @changeset_pages,@changeset_count %>

+<%if @changesets %> +

<%= link_to l(:label_fetch_more_revisions), :action => "fetch_revisions", :id => @project, :path => '' %>

+<%end%> + <% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> Index: app/views/repositories/show.rhtml =================================================================== --- app/views/repositories/show.rhtml (revision 4794) +++ app/views/repositories/show.rhtml (working copy) @@ -17,7 +17,11 @@ <%= render :partial => 'revisions', :locals => {:project => @project, :path => @path, :revisions => @changesets, :entry => nil }%> <% if @path.blank? %> -

<%= link_to l(:label_view_all_revisions), :action => 'revisions', :id => @project %>

+

<%= link_to l(:label_view_all_revisions), :action => 'revisions', :id => @project %> + <%if @changesets %> + <%= link_to l(:label_fetch_more_revisions), :action => "fetch_revisions", :id => @project, :path => '' %> + <%end%> +

<% else %>

<%= link_to l(:label_view_revisions), :action => 'changes', :path => to_path_param(@path), :id => @project %>

<% end %> Index: config/locales/en-GB.yml =================================================================== --- config/locales/en-GB.yml (revision 4794) +++ config/locales/en-GB.yml (working copy) @@ -940,3 +940,4 @@ setting_commit_logtime_enabled: Enable time logging notice_gantt_chart_truncated: The chart was truncated because it exceeds the maximum number of items that can be displayed (%{max}) setting_gantt_items_limit: Maximum number of items displayed on the gantt chart + label_fetch_more_revisions: Fetch more revisions Index: config/locales/en.yml =================================================================== --- config/locales/en.yml (revision 4794) +++ config/locales/en.yml (working copy) @@ -639,6 +639,7 @@ label_latest_revision_plural: Latest revisions label_view_revisions: View revisions label_view_all_revisions: View all revisions + label_fetch_more_revisions: Fetch more revisions label_max_size: Maximum size label_sort_highest: Move to top label_sort_higher: Move up Index: lib/redmine.rb =================================================================== --- lib/redmine.rb (revision 4794) +++ lib/redmine.rb (working copy) @@ -122,7 +122,7 @@ map.project_module :repository do |map| map.permission :manage_repository, {:repositories => [:edit, :committers, :destroy]}, :require => :member map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] - map.permission :view_changesets, :repositories => [:show, :revisions, :revision] + map.permission :view_changesets, :repositories => [:show, :revisions, :revision, :fetch_revisions] map.permission :commit_access, {} end