Mercurial > hg > soundsoftware-site
comparison app/models/changeset.rb @ 3:7c48bad7d85d yuya
* Import Mercurial overhaul patches from Yuya Nishihara (see http://www.redmine.org/issues/4455)
author | Chris Cannam |
---|---|
date | Wed, 28 Jul 2010 12:40:01 +0100 |
parents | 513646585e45 |
children | 9c6c72729d91 |
comparison
equal
deleted
inserted
replaced
2:b940d200fbd2 | 3:7c48bad7d85d |
---|---|
21 belongs_to :repository | 21 belongs_to :repository |
22 belongs_to :user | 22 belongs_to :user |
23 has_many :changes, :dependent => :delete_all | 23 has_many :changes, :dependent => :delete_all |
24 has_and_belongs_to_many :issues | 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)} #{RepositoriesHelper.format_revision(o)}" + (o.short_comments.blank? ? '' : (': ' + o.short_comments))}, |
27 :description => :long_comments, | 27 :description => :long_comments, |
28 :datetime => :committed_on, | 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 acts_as_searchable :columns => 'comments', | 31 acts_as_searchable :columns => 'comments', |
32 :include => {:repository => :project}, | 32 :include => {:repository => :project}, |
33 :project_key => "#{Repository.table_name}.project_id", | 33 :project_key => "#{Repository.table_name}.project_id", |
34 :date_column => 'committed_on' | 34 :date_column => 'committed_on' |
45 :conditions => Project.allowed_to_condition(args.first || User.current, :view_changesets) } } | 45 :conditions => Project.allowed_to_condition(args.first || User.current, :view_changesets) } } |
46 | 46 |
47 def revision=(r) | 47 def revision=(r) |
48 write_attribute :revision, (r.nil? ? nil : r.to_s) | 48 write_attribute :revision, (r.nil? ? nil : r.to_s) |
49 end | 49 end |
50 | |
51 # Returns the identifier of this changeset. | |
52 # e.g. revision number for centralized system; hash id for DVCS | |
53 def identifier | |
54 scmid || revision | |
55 end | |
56 | |
57 # Returns the wiki identifier, "rN" or "commit:ABCDEF" | |
58 def wiki_identifier | |
59 if scmid # hash-like | |
60 "commit:#{scmid}" | |
61 else # numeric | |
62 "r#{revision}" | |
63 end | |
64 end | |
65 private :wiki_identifier | |
50 | 66 |
51 def comments=(comment) | 67 def comments=(comment) |
52 write_attribute(:comments, Changeset.normalize_comments(comment)) | 68 write_attribute(:comments, Changeset.normalize_comments(comment)) |
53 end | 69 end |
54 | 70 |
107 target_issues.each do |issue| | 123 target_issues.each do |issue| |
108 # the issue may have been updated by the closure of another one (eg. duplicate) | 124 # the issue may have been updated by the closure of another one (eg. duplicate) |
109 issue.reload | 125 issue.reload |
110 # don't change the status is the issue is closed | 126 # don't change the status is the issue is closed |
111 next if issue.status.is_closed? | 127 next if issue.status.is_closed? |
112 csettext = "r#{self.revision}" | 128 journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, wiki_identifier)) |
113 if self.scmid && (! (csettext =~ /^r[0-9]+$/)) | |
114 csettext = "commit:\"#{self.scmid}\"" | |
115 end | |
116 journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, csettext)) | |
117 issue.status = fix_status | 129 issue.status = fix_status |
118 unless Setting.commit_fix_done_ratio.blank? | 130 unless Setting.commit_fix_done_ratio.blank? |
119 issue.done_ratio = Setting.commit_fix_done_ratio.to_i | 131 issue.done_ratio = Setting.commit_fix_done_ratio.to_i |
120 end | 132 end |
121 Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update, | 133 Redmine::Hook.call_hook(:model_changeset_scan_commit_for_issue_ids_pre_issue_update, |