diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 0a95c6a..539dcd9 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -28,7 +28,6 @@ class RepositoriesController < ApplicationController default_search_scope :changesets before_filter :find_project_by_project_id, :only => [:new, :create] - before_filter :check_repository_uniqueness, :only => [:new, :create] before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] before_filter :find_project_repository, :except => [:new, :create, :edit, :update, :destroy, :committers] before_filter :authorize @@ -39,6 +38,7 @@ class RepositoriesController < ApplicationController def new scm = params[:repository_scm] || Redmine::Scm::Base.all.first @repository = Repository.factory(scm) + @repository.is_default = @project.repository.nil? @repository.project = @project render :layout => !request.xhr? end @@ -97,6 +97,7 @@ class RepositoriesController < ApplicationController (show_error_not_found; return) unless @entries @changesets = @repository.latest_changesets(@path, @rev) @properties = @repository.properties(@path, @rev) + @repositories = @project.repositories render :action => 'show' end end @@ -255,18 +256,15 @@ class RepositoriesController < ApplicationController render_404 end - # TODO: remove it when multiple SCM support is added - def check_repository_uniqueness - if @project.repository - redirect_to settings_project_path(@project, :tab => 'repositories') - end - end - REV_PARAM_RE = %r{\A[a-f0-9]*\Z}i def find_project_repository @project = Project.find(params[:id]) - @repository = @project.repository + if params[:repository_id].present? + @repository = @project.repositories.find_by_identifier_param(params[:repository_id]) + else + @repository = @project.repository + end (render_404; return false) unless @repository @path = params[:path].join('/') unless params[:path].nil? @path ||= '' diff --git a/app/controllers/sys_controller.rb b/app/controllers/sys_controller.rb index 89ad19a..0644fed 100644 --- a/app/controllers/sys_controller.rb +++ b/app/controllers/sys_controller.rb @@ -19,7 +19,7 @@ class SysController < ActionController::Base before_filter :check_enabled def projects - p = Project.active.has_module(:repository).find(:all, :include => :repository, :order => 'identifier') + p = Project.active.has_module(:repository).find(:all, :include => :repository, :order => "#{Project.table_name}.identifier") # extra_info attribute from repository breaks activeresource client render :xml => p.to_xml(:only => [:id, :identifier, :name, :is_public, :status], :include => {:repository => {:only => [:id, :url]}}) end @@ -44,11 +44,11 @@ class SysController < ActionController::Base if params[:id] projects << Project.active.has_module(:repository).find(params[:id]) else - projects = Project.active.has_module(:repository).find(:all, :include => :repository) + projects = Project.active.has_module(:repository).all end projects.each do |project| - if project.repository - project.repository.fetch_changesets + project.repositories.each do |repository| + repository.fetch_changesets end end render :nothing => true, :status => 200 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1954351..9684200 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -106,12 +106,15 @@ module ApplicationHelper # Generates a link to a SCM revision # Options: # * :text - Link text (default to the formatted revision) - def link_to_revision(revision, project, options={}) + def link_to_revision(revision, repository, options={}) + if repository.is_a?(Project) + repository = repository.repository + end text = options.delete(:text) || format_revision(revision) rev = revision.respond_to?(:identifier) ? revision.identifier : revision link_to( h(text), - {:controller => 'repositories', :action => 'revision', :id => project, :rev => rev}, + {:controller => 'repositories', :action => 'revision', :id => repository.project, :repository_id => repository.identifier_param, :rev => rev}, :title => l(:label_revision_id, format_revision(revision)) ) end diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index f3b229f..2480713 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -92,6 +92,7 @@ module RepositoriesHelper text = link_to(h(text), :controller => 'repositories', :action => 'show', :id => @project, + :repository_id => @repository.identifier_param, :path => path_param, :rev => @changeset.identifier) output << "
<%= link_to_revision(changeset, changeset.project, +
<%= link_to_revision(changeset, changeset.repository,
:text => "#{l(:label_revision)} #{changeset.format_identifier}") %>
<%= l(:label_scm) %> | +<%= l(:field_identifier) %> | +<%= l(:field_repository_is_default) %> | <%= l(:label_repository) %> | |
---|---|---|---|---|
<%=h repository.scm_name %> | +<%=h repository.identifier %> | +<%= checked_image repository.is_default? %> | <%=h repository.url %> | <% if User.current.allowed_to?(:manage_repository, @project) %> @@ -25,12 +29,13 @@ <% end %> |
<%= l(:label_no_data) %>
<% end %> -<% if @project.repository.nil? && User.current.allowed_to?(:manage_repository, @project) %> +<% if User.current.allowed_to?(:manage_repository, @project) %><%= link_to l(:label_repository_new), new_project_repository_path(@project), :class => 'icon icon-add' %>
<% end %> diff --git a/app/views/repositories/_breadcrumbs.html.erb b/app/views/repositories/_breadcrumbs.html.erb index 0d54817..1a610ff 100644 --- a/app/views/repositories/_breadcrumbs.html.erb +++ b/app/views/repositories/_breadcrumbs.html.erb @@ -1,4 +1,4 @@ -<%= link_to 'root', :action => 'show', :id => @project, :path => '', :rev => @rev %> +<%= link_to 'root', :action => 'show', :id => @project, :repository_id => @repository.identifier_param, :path => '', :rev => @rev %> <% dirs = path.split('/') if 'file' == kind @@ -10,12 +10,12 @@ dirs.each do |dir| link_path << '/' unless link_path.empty? link_path << "#{dir}" %> - / <%= link_to h(dir), :action => 'show', :id => @project, + / <%= link_to h(dir), :action => 'show', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(link_path), :rev => @rev %> <% end %> <% if filename %> / <%= link_to h(filename), - :action => 'changes', :id => @project, + :action => 'changes', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param("#{link_path}/#{filename}"), :rev => @rev %> <% end %> <% diff --git a/app/views/repositories/_dir_list_content.html.erb b/app/views/repositories/_dir_list_content.html.erb index 4a1779e..057b7dc 100644 --- a/app/views/repositories/_dir_list_content.html.erb +++ b/app/views/repositories/_dir_list_content.html.erb @@ -11,6 +11,7 @@ :url => { :action => 'show', :id => @project, + :repository_id => @repository.identifier_param, :path => to_path_param(ent_path), :rev => @rev, :depth => (depth + 1), @@ -24,13 +25,13 @@ ) %>">  <% end %> <%= link_to h(ent_name), - {:action => (entry.is_dir? ? 'show' : 'changes'), :id => @project, :path => to_path_param(ent_path), :rev => @rev}, + {:action => (entry.is_dir? ? 'show' : 'changes'), :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(ent_path), :rev => @rev}, :class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%><%= f.text_field :identifier %>
+<%= f.check_box :is_default, :label => :field_repository_is_default %>
+ <% button_disabled = true %> <% if @repository %> <% button_disabled = ! @repository.class.scm_available %> diff --git a/app/views/repositories/_link_to_functions.html.erb b/app/views/repositories/_link_to_functions.html.erb index 412d5f8..aed88eb 100644 --- a/app/views/repositories/_link_to_functions.html.erb +++ b/app/views/repositories/_link_to_functions.html.erb @@ -1,14 +1,14 @@ <% if @entry && @entry.kind == 'file' %>-<%= link_to_if action_name != 'changes', l(:label_history), {:action => 'changes', :id => @project, :path => to_path_param(@path), :rev => @rev } %> | +<%= link_to_if action_name != 'changes', l(:label_history), {:action => 'changes', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(@path), :rev => @rev } %> | <% if @repository.supports_cat? %> - <%= link_to_if action_name != 'entry', l(:button_view), {:action => 'entry', :id => @project, :path => to_path_param(@path), :rev => @rev } %> | + <%= link_to_if action_name != 'entry', l(:button_view), {:action => 'entry', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(@path), :rev => @rev } %> | <% end %> <% if @repository.supports_annotate? %> - <%= link_to_if action_name != 'annotate', l(:button_annotate), {:action => 'annotate', :id => @project, :path => to_path_param(@path), :rev => @rev } %> | + <%= link_to_if action_name != 'annotate', l(:button_annotate), {:action => 'annotate', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(@path), :rev => @rev } %> | <% end %> -<%= link_to(l(:button_download), {:action => 'entry', :id => @project, :path => to_path_param(@path), :rev => @rev, :format => 'raw' }) if @repository.supports_cat? %> +<%= link_to(l(:button_download), {:action => 'entry', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(@path), :rev => @rev, :format => 'raw' }) if @repository.supports_cat? %> <%= "(#{number_to_human_size(@entry.size)})" if @entry.size %>
diff --git a/app/views/repositories/_navigation.html.erb b/app/views/repositories/_navigation.html.erb index 706f06c..05c19d9 100644 --- a/app/views/repositories/_navigation.html.erb +++ b/app/views/repositories/_navigation.html.erb @@ -3,11 +3,12 @@ <% end %> <%= link_to l(:label_statistics), - {:action => 'stats', :id => @project}, + {:action => 'stats', :id => @project, :repository_id => @repository.identifier_param}, :class => 'icon icon-stats' %> <% form_tag({:action => controller.action_name, :id => @project, + :repository_id => @repository.identifier_param, :path => to_path_param(@path), :rev => ''}, {:method => :get, :id => 'revision_selector'}) do -%> diff --git a/app/views/repositories/_revisions.html.erb b/app/views/repositories/_revisions.html.erb index ea55e4b..3fd1cf6 100644 --- a/app/views/repositories/_revisions.html.erb +++ b/app/views/repositories/_revisions.html.erb @@ -1,5 +1,5 @@ <% show_revision_graph = ( @repository.supports_revision_graph? && path.blank? ) %> -<% form_tag({:controller => 'repositories', :action => 'diff', :id => @project, :path => to_path_param(path)}, :method => :get) do %> +<% form_tag({:controller => 'repositories', :action => 'diff', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(path)}, :method => :get) do %><%= link_to_revision(changeset, project) %> | +<%= link_to_revision(changeset, @repository) %> | <%= radio_button_tag('rev', changeset.identifier, (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.identifier, (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/annotate.html.erb b/app/views/repositories/annotate.html.erb index 444ae2a..188d921 100644 --- a/app/views/repositories/annotate.html.erb +++ b/app/views/repositories/annotate.html.erb @@ -19,7 +19,7 @@
<%= line_num %> | - <%= (revision.identifier ? link_to_revision(revision, @project) : format_revision(revision)) if revision %> | + <%= (revision.identifier ? link_to_revision(revision, @repository) : format_revision(revision)) if revision %><%= h(revision.author.to_s.split('<').first) if revision %> | <%= line %> |
<%= l(:label_parent_revision) %> | <%= @changeset.parents.collect{ - |p| link_to_revision(p, @project, :text => format_revision(p)) + |p| link_to_revision(p, @repository, :text => format_revision(p)) }.join(", ").html_safe %> | @@ -47,7 +48,7 @@<%= l(:label_child_revision) %> | <%= @changeset.children.collect{ - |p| link_to_revision(p, @project, :text => format_revision(p)) + |p| link_to_revision(p, @repository, :text => format_revision(p)) }.join(", ").html_safe %> | @@ -85,6 +86,7 @@
---|