Feature #6092 » yuya-issue-4455-mq-ab997af9e-exclude-hg.diff
app/controllers/issues_controller.rb | ||
---|---|---|
43 | 43 |
include AttachmentsHelper |
44 | 44 |
helper :queries |
45 | 45 |
include QueriesHelper |
46 |
helper :repositories |
|
47 |
include RepositoriesHelper |
|
46 | 48 |
helper :sort |
47 | 49 |
include SortHelper |
48 | 50 |
include IssuesHelper |
app/helpers/application_helper.rb | ||
---|---|---|
118 | 118 |
# * :text - Link text (default to the formatted revision) |
119 | 119 |
def link_to_revision(revision, project, options={}) |
120 | 120 |
text = options.delete(:text) || format_revision(revision) |
121 |
rev = revision.respond_to?(:identifier) ? revision.identifier : revision |
|
121 | 122 | |
122 |
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => revision}, :title => l(:label_revision_id, revision)) |
|
123 |
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => rev}, |
|
124 |
:title => l(:label_revision_id, format_revision(revision))) |
|
123 | 125 |
end |
124 | 126 |
|
125 | 127 |
def link_to_project(project, options={}) |
... | ... | |
665 | 667 |
end |
666 | 668 |
when 'commit' |
667 | 669 |
if project && (changeset = project.changesets.find(:first, :conditions => ["scmid LIKE ?", "#{name}%"])) |
668 |
link = link_to h("#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision},
|
|
670 |
link = link_to h("#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.identifier},
|
|
669 | 671 |
:class => 'changeset', |
670 | 672 |
:title => truncate_single_line(changeset.comments, :length => 100) |
671 | 673 |
end |
app/helpers/repositories_helper.rb | ||
---|---|---|
18 | 18 |
require 'iconv' |
19 | 19 | |
20 | 20 |
module RepositoriesHelper |
21 |
def format_revision(txt) |
|
22 |
txt.to_s[0,8] |
|
21 |
def format_revision(revision) |
|
22 |
if revision.respond_to? :format_identifier |
|
23 |
revision.format_identifier |
|
24 |
else |
|
25 |
revision.to_s[0,8] |
|
26 |
end |
|
23 | 27 |
end |
24 | 28 |
|
25 | 29 |
def truncate_at_line_break(text, length = 255) |
... | ... | |
87 | 91 |
:action => 'show', |
88 | 92 |
:id => @project, |
89 | 93 |
:path => path_param, |
90 |
:rev => @changeset.revision)
|
|
94 |
:rev => @changeset.identifier)
|
|
91 | 95 |
output << "<li class='#{style}'>#{text}</li>" |
92 | 96 |
output << render_changes_tree(s) |
93 | 97 |
elsif c = tree[file][:c] |
... | ... | |
97 | 101 |
:action => 'entry', |
98 | 102 |
:id => @project, |
99 | 103 |
:path => path_param, |
100 |
:rev => @changeset.revision) unless c.action == 'D'
|
|
104 |
:rev => @changeset.identifier) unless c.action == 'D'
|
|
101 | 105 |
text << " - #{c.revision}" unless c.revision.blank? |
102 | 106 |
text << ' (' + link_to('diff', :controller => 'repositories', |
103 | 107 |
:action => 'diff', |
104 | 108 |
:id => @project, |
105 | 109 |
:path => path_param, |
106 |
:rev => @changeset.revision) + ') ' if c.action == 'M'
|
|
110 |
:rev => @changeset.identifier) + ') ' if c.action == 'M'
|
|
107 | 111 |
text << ' ' + content_tag('span', c.from_path, :class => 'copied-from') unless c.from_path.blank? |
108 | 112 |
output << "<li class='#{style}'>#{text}</li>" |
109 | 113 |
end |
app/models/changeset.rb | ||
---|---|---|
23 | 23 |
has_many :changes, :dependent => :delete_all |
24 | 24 |
has_and_belongs_to_many :issues |
25 | 25 | |
26 |
acts_as_event :title => Proc.new {|o| "#{l(:label_revision)} #{o.revision}" + (o.short_comments.blank? ? '' : (': ' + o.short_comments))},
|
|
26 |
acts_as_event :title => Proc.new {|o| "#{l(:label_revision)} #{o.format_identifier}" + (o.short_comments.blank? ? '' : (': ' + o.short_comments))},
|
|
27 | 27 |
:description => :long_comments, |
28 | 28 |
:datetime => :committed_on, |
29 |
:url => Proc.new {|o| {:controller => 'repositories', :action => 'revision', :id => o.repository.project, :rev => o.revision}}
|
|
29 |
:url => Proc.new {|o| {:controller => 'repositories', :action => 'revision', :id => o.repository.project, :rev => o.identifier}}
|
|
30 | 30 |
|
31 | 31 |
acts_as_searchable :columns => 'comments', |
32 | 32 |
:include => {:repository => :project}, |
... | ... | |
48 | 48 |
write_attribute :revision, (r.nil? ? nil : r.to_s) |
49 | 49 |
end |
50 | 50 |
|
51 |
# Returns the identifier of this changeset. |
|
52 |
# e.g. revision number for centralized system; hash id for DVCS |
|
53 |
def identifier |
|
54 |
## Temporary comment out. |
|
55 |
## Because All DVCS need to implement find_changeset_by_name(name). |
|
56 |
# (scmid || revision).to_s |
|
57 |
revision.to_s |
|
58 |
end |
|
59 | ||
60 |
# Returns the readable identifier; first 8 chars of identifier by default |
|
61 |
def format_identifier |
|
62 |
if repository.class.respond_to? :format_changeset_identifier |
|
63 |
repository.class.format_changeset_identifier self |
|
64 |
else |
|
65 |
identifier[0, 8] |
|
66 |
end |
|
67 |
end |
|
68 | ||
69 |
# Returns the identifier for wiki, "rN" or "commit:ABCDEF" |
|
70 |
def format_wiki_identifier |
|
71 |
if scmid # hash-like |
|
72 |
"commit:#{scmid}" |
|
73 |
else # numeric |
|
74 |
"r#{revision}" |
|
75 |
end |
|
76 |
end |
|
77 |
|
|
51 | 78 |
def comments=(comment) |
52 | 79 |
write_attribute(:comments, Changeset.normalize_comments(comment)) |
53 | 80 |
end |
... | ... | |
108 | 135 |
issue.reload |
109 | 136 |
# don't change the status is the issue is closed |
110 | 137 |
next if issue.status.is_closed? |
111 |
csettext = "r#{self.revision}" |
|
112 |
if self.scmid && (! (csettext =~ /^r[0-9]+$/)) |
|
113 |
csettext = "commit:\"#{self.scmid}\"" |
|
114 |
end |
|
115 |
journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, csettext)) |
|
138 |
journal = issue.init_journal(user || User.anonymous, |
|
139 |
ll(Setting.default_language, :text_status_changed_by_changeset, format_wiki_identifier)) |
|
116 | 140 |
issue.status = fix_status |
117 | 141 |
unless Setting.commit_fix_done_ratio.blank? |
118 | 142 |
issue.done_ratio = Setting.commit_fix_done_ratio.to_i |
app/models/repository.rb | ||
---|---|---|
172 | 172 |
def self.fetch_changesets |
173 | 173 |
Project.active.has_module(:repository).find(:all, :include => :repository).each do |project| |
174 | 174 |
if project.repository |
175 |
begin |
|
175 | 176 |
project.repository.fetch_changesets |
177 |
rescue Redmine::Scm::Adapters::CommandFailed => e |
|
178 |
logger.error "Repository: error during fetching changesets: #{e.message}" |
|
179 |
end |
|
176 | 180 |
end |
177 | 181 |
end |
178 | 182 |
end |
app/views/issues/_changesets.rhtml | ||
---|---|---|
1 | 1 |
<% changesets.each do |changeset| %> |
2 | 2 |
<div class="changeset <%= cycle('odd', 'even') %>"> |
3 |
<p><%= link_to("#{l(:label_revision)} #{changeset.revision}",
|
|
4 |
:controller => 'repositories', :action => 'revision', :id => changeset.project, :rev => changeset.revision) %><br />
|
|
3 |
<p><%= link_to_revision(changeset, changeset.project,
|
|
4 |
:text => "#{l(:label_revision)} #{changeset.format_identifier}") %><br />
|
|
5 | 5 |
<span class="author"><%= authoring(changeset.committed_on, changeset.author) %></span></p> |
6 | 6 |
<div class="changeset-changes"> |
7 | 7 |
<%= textilizable(changeset, :comments) %> |
app/views/repositories/_dir_list_content.rhtml | ||
---|---|---|
17 | 17 |
</td> |
18 | 18 |
<td class="size"><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td> |
19 | 19 |
<% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %> |
20 |
<td class="revision"><%= link_to_revision(changeset.revision, @project) if changeset %></td>
|
|
20 |
<td class="revision"><%= link_to_revision(changeset, @project) if changeset %></td> |
|
21 | 21 |
<td class="age"><%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %></td> |
22 | 22 |
<td class="author"><%= changeset.nil? ? h(entry.lastrev.author.to_s.split('<').first) : changeset.author if entry.lastrev %></td> |
23 | 23 |
<td class="comments"><%=h truncate(changeset.comments, :length => 50) unless changeset.nil? %></td> |
app/views/repositories/_revisions.rhtml | ||
---|---|---|
13 | 13 |
<% line_num = 1 %> |
14 | 14 |
<% revisions.each do |changeset| %> |
15 | 15 |
<tr class="changeset <%= cycle 'odd', 'even' %>"> |
16 |
<td class="id"><%= link_to_revision(changeset.revision, project) %></td>
|
|
17 |
<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>
|
|
18 |
<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>
|
|
16 |
<td class="id"><%= link_to_revision(changeset, project) %></td> |
|
17 |
<td class="checkbox"><%= 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) %></td>
|
|
18 |
<td class="checkbox"><%= 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) %></td>
|
|
19 | 19 |
<td class="committed_on"><%= format_time(changeset.committed_on) %></td> |
20 | 20 |
<td class="author"><%=h changeset.author %></td> |
21 | 21 |
<td class="comments"><%= textilizable(truncate_at_line_break(changeset.comments)) %></td> |
app/views/repositories/annotate.rhtml | ||
---|---|---|
19 | 19 |
<tr class="bloc-<%= revision.nil? ? 0 : colors[revision.identifier || revision.revision] %>"> |
20 | 20 |
<th class="line-num" id="L<%= line_num %>"><a href="#L<%= line_num %>"><%= line_num %></a></th> |
21 | 21 |
<td class="revision"> |
22 |
<%= (revision.identifier ? link_to(format_revision(revision.identifier), :action => 'revision', :id => @project, :rev => revision.identifier) : format_revision(revision.revision)) if revision %></td>
|
|
22 |
<%= (revision.identifier ? link_to_revision(revision, @project) : format_revision(revision)) if revision %></td>
|
|
23 | 23 |
<td class="author"><%= h(revision.author.to_s.split('<').first) if revision %></td> |
24 | 24 |
<td class="line-code"><pre><%= line %></pre></td> |
25 | 25 |
</tr> |
app/views/repositories/revision.rhtml | ||
---|---|---|
1 | 1 |
<div class="contextual"> |
2 | 2 |
« |
3 | 3 |
<% unless @changeset.previous.nil? -%> |
4 |
<%= link_to_revision(@changeset.previous.revision, @project, :text => l(:label_previous)) %>
|
|
4 |
<%= link_to_revision(@changeset.previous, @project, :text => l(:label_previous)) %> |
|
5 | 5 |
<% else -%> |
6 | 6 |
<%= l(:label_previous) %> |
7 | 7 |
<% end -%> |
8 | 8 |
| |
9 | 9 |
<% unless @changeset.next.nil? -%> |
10 |
<%= link_to_revision(@changeset.next.revision, @project, :text => l(:label_next)) %>
|
|
10 |
<%= link_to_revision(@changeset.next, @project, :text => l(:label_next)) %> |
|
11 | 11 |
<% else -%> |
12 | 12 |
<%= l(:label_next) %> |
13 | 13 |
<% end -%> |
14 | 14 |
» |
15 | 15 | |
16 | 16 |
<% form_tag({:controller => 'repositories', :action => 'revision', :id => @project, :rev => nil}, :method => :get) do %> |
17 |
<%= text_field_tag 'rev', @rev[0,8], :size => 8 %>
|
|
17 |
<%= text_field_tag 'rev', @rev, :size => 8 %> |
|
18 | 18 |
<%= submit_tag 'OK', :name => nil %> |
19 | 19 |
<% end %> |
20 | 20 |
</div> |
21 | 21 | |
22 |
<h2><%= l(:label_revision) %> <%= format_revision(@changeset.revision) %></h2>
|
|
22 |
<h2><%= l(:label_revision) %> <%= format_revision(@changeset) %></h2> |
|
23 | 23 | |
24 | 24 |
<p><% if @changeset.scmid %>ID: <%= @changeset.scmid %><br /><% end %> |
25 | 25 |
<span class="author"><%= authoring(@changeset.committed_on, @changeset.author) %></span></p> |
... | ... | |
45 | 45 |
<li class="change change-D"><%= l(:label_deleted) %></li> |
46 | 46 |
</ul> |
47 | 47 | |
48 |
<p><%= link_to(l(:label_view_diff), :action => 'diff', :id => @project, :path => "", :rev => @changeset.revision) if @changeset.changes.any? %></p>
|
|
48 |
<p><%= link_to(l(:label_view_diff), :action => 'diff', :id => @project, :path => "", :rev => @changeset.identifier) if @changeset.changes.any? %></p>
|
|
49 | 49 | |
50 | 50 |
<div class="changeset-changes"> |
51 | 51 |
<%= render_changeset_changes %> |
lib/redmine/scm/adapters/abstract_adapter.rb | ||
---|---|---|
271 | 271 |
end |
272 | 272 |
|
273 | 273 |
class Revision |
274 |
attr_accessor :identifier, :scmid, :name, :author, :time, :message, :paths, :revision, :branch |
|
274 |
attr_accessor :scmid, :name, :author, :time, :message, :paths, :revision, :branch |
|
275 |
attr_writer :identifier |
|
275 | 276 | |
276 | 277 |
def initialize(attributes={}) |
277 | 278 |
self.identifier = attributes[:identifier] |
... | ... | |
285 | 286 |
self.branch = attributes[:branch] |
286 | 287 |
end |
287 | 288 | |
289 |
# Returns the identifier of this revision. |
|
290 |
# e.g. revision number for centralized system; hash id for DVCS |
|
291 |
def identifier |
|
292 |
(@identifier || scmid || revision).to_s |
|
293 |
end |
|
294 | ||
295 |
# Returns the readable identifier; first 8 chars of identifier. |
|
296 |
def format_identifier |
|
297 |
identifier[0, 8] |
|
298 |
end |
|
299 | ||
288 | 300 |
def save(repo) |
289 | 301 |
Changeset.transaction do |
290 | 302 |
changeset = Changeset.new( |