Index: app/helpers/changeset_relations_helper.rb
===================================================================
--- app/helpers/changeset_relations_helper.rb (revision 0)
+++ app/helpers/changeset_relations_helper.rb (revision 0)
@@ -0,0 +1,2 @@
+module ChangesetRelationsHelper
+end
\ No newline at end of file
Index: app/controllers/changeset_relations_controller.rb
===================================================================
--- app/controllers/changeset_relations_controller.rb (revision 0)
+++ app/controllers/changeset_relations_controller.rb (revision 0)
@@ -0,0 +1,53 @@
+class ChangesetRelationsController < ApplicationController
+
+
+ before_filter :find_project, :authorize
+
+ def new
+ @changeset = Changeset.find(:first, :conditions => {:revision => params[:changeset][:revision], :repository_id => @project.repository})
+ if @changeset.nil?
+ @changeset = Changeset.new(:revision => params[:changeset][:revision])
+ @changeset.errors.add l(:field_error_revision_not_found)
+ else
+ @changeset.issues << @issue
+ @changeset.save if request.post?
+ end
+ @issue.reload
+ respond_to do |format|
+ format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
+ format.js do
+ render :update do |page|
+ page.replace_html "issue-changesets-list", :partial => 'issues/changesets', :locals => { :changesets => @issue.changesets}
+ if @changeset.errors.empty?
+ page << "$('changeset_revision').value = ''"
+ end
+ end
+ end
+ end
+ end
+
+ def destroy
+ changeset = Changeset.find(params[:id])
+ if request.post? && ! changeset.nil? && changeset.issues.include?(@issue)
+ changeset.issues.delete(@issue)
+ @issue.reload
+ end
+ respond_to do |format|
+ format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
+ format.js do
+ render(:update) do |page|
+ page.replace_html "issue-changesets-list", :partial => 'issues/changesets', :locals => { :changesets => @issue.changesets}
+ end
+ end
+ end
+ end
+
+
+ private
+ def find_project
+ @issue = Issue.find(params[:issue_id])
+ @project = @issue.project
+ rescue ActiveRecord::RecordNotFound
+ render_404
+ end
+end
\ No newline at end of file
Index: app/views/changeset_relations/_form.html.erb
===================================================================
--- app/views/changeset_relations/_form.html.erb (revision 0)
+++ app/views/changeset_relations/_form.html.erb (revision 0)
@@ -0,0 +1,8 @@
+<%= error_messages_for 'changeset' %>
+
+
<%= l(:label_revision) %> <%= f.text_field :revision, :size => 6 %>
+<%= submit_tag l(:button_add) %>
+<%= toggle_link l(:button_cancel), 'new-changeset-form'%>
+
+
+<%= javascript_tag "setPredecessorFieldsVisibility();" %>
\ No newline at end of file
Index: app/views/issues/show.rhtml
===================================================================
--- app/views/issues/show.rhtml (revision 3078)
+++ app/views/issues/show.rhtml (working copy)
@@ -82,9 +82,18 @@
<% if @changesets.any? && User.current.allowed_to?(:view_changesets, @project) %>
+
+<% if authorize_for('changeset_relations', 'new') %>
+ <%= toggle_link l(:button_add), 'new-changeset-form'%>
+<% end %>
+
+
<%=l(:label_associated_revisions)%>
+
+
<%= render :partial => 'changesets', :locals => { :changesets => @changesets} %>
+
<% end %>
<% if @journals.any? %>
Index: app/views/issues/_changesets.rhtml
===================================================================
--- app/views/issues/_changesets.rhtml (revision 3078)
+++ app/views/issues/_changesets.rhtml (working copy)
@@ -1,8 +1,21 @@
+<% remote_form_for(:changeset, @changeset,
+ :url => {:controller => 'changeset_relations', :action => 'new', :issue_id => @issue},
+ :method => :post,
+ :html => {:id => 'new-changeset-form', :style => (@changeset ? '' : 'display: none;')}) do |f| %>
+<%= render :partial => 'changeset_relations/form', :locals => {:f => f}%>
+<% end %>
+
<% changesets.each do |changeset| %>
<%= link_to("#{l(:label_revision)} #{changeset.revision}",
- :controller => 'repositories', :action => 'revision', :id => changeset.project, :rev => changeset.revision) %>
- <%= authoring(changeset.committed_on, changeset.author) %>
+ :controller => 'repositories', :action => 'revision', :id => changeset.project, :rev => changeset.revision) %>
+
+ <%= link_to_remote(image_tag('delete.png'), { :url => {:controller => 'changeset_relations', :action => 'destroy', :issue_id => @issue, :id => changeset},
+ :method => :post
+ }, :title => l(:label_changeset_delete)) if authorize_for('changeset_relations', 'destroy') %>
+
+
+
<%= authoring(changeset.committed_on, changeset.author) %>
<%= textilizable(changeset, :comments) %>
<% end %>
Index: db/migrate/20091124053250_add_manage_changeset_relations_permission.rb
===================================================================
--- db/migrate/20091124053250_add_manage_changeset_relations_permission.rb (revision 0)
+++ db/migrate/20091124053250_add_manage_changeset_relations_permission.rb (revision 0)
@@ -0,0 +1,13 @@
+class AddManageChangesetRelationsPermission < ActiveRecord::Migration
+ def self.up
+ Role.find(:all).each do |r|
+ r.add_permission!(:manage_changeset_relations) if r.has_permission?(:manage_issue_relations)
+ end
+ end
+
+ def self.down
+ Role.find(:all).each do |r|
+ r.remove_permission!(:manage_changeset_relations)
+ end
+ end
+end
Index: config/locales/en.yml
===================================================================
--- config/locales/en.yml (revision 3078)
+++ config/locales/en.yml (working copy)
@@ -840,3 +841,6 @@
enumeration_doc_categories: Document categories
enumeration_activities: Activities (time tracking)
enumeration_system_activity: System Activity
+
+ label_changeset_delete: Delete associated revision
+ field_error_revision_not_found: Revision not found at project SCM
Index: lib/redmine.rb
===================================================================
--- lib/redmine.rb (revision 3078)
+++ lib/redmine.rb (working copy)
@@ -45,6 +45,7 @@
map.permission :add_issues, {:issues => :new}
map.permission :edit_issues, {:issues => [:edit, :reply, :bulk_edit]}
map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
+ map.permission :manage_changeset_relations, {:changeset_relations => [:new, :destroy]}
map.permission :add_issue_notes, {:issues => [:edit, :reply]}
map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin