@@ -88,13 +88,7 module Redmine | |||||
88 | value = $2 |
|
88 | value = $2 | |
89 | if parsing_descr && line_feeds > 1 |
|
89 | if parsing_descr && line_feeds > 1 | |
90 | parsing_descr = false |
|
90 | parsing_descr = false | |
91 |
revisions << |
|
91 | revisions << build_revision_from_changeset(changeset) | |
92 | :scmid => changeset[:changeset].split(':').last, |
|
|||
93 | :author => changeset[:user], |
|
|||
94 | :time => Time.parse(changeset[:date]), |
|
|||
95 | :message => changeset[:description], |
|
|||
96 | :paths => changeset[:files].to_s.split.collect{|path| {:action => 'X', :path => "/#{path}"}} |
|
|||
97 | }) |
|
|||
98 | changeset = {} |
|
92 | changeset = {} | |
99 | end |
|
93 | end | |
100 | if !parsing_descr |
|
94 | if !parsing_descr | |
@@ -111,13 +105,7 module Redmine | |||||
111 | line_feeds += 1 if line.chomp.empty? |
|
105 | line_feeds += 1 if line.chomp.empty? | |
112 | end |
|
106 | end | |
113 | end |
|
107 | end | |
114 |
revisions << |
|
108 | revisions << build_revision_from_changeset(changeset) | |
115 | :scmid => changeset[:changeset].split(':').last, |
|
|||
116 | :author => changeset[:user], |
|
|||
117 | :time => Time.parse(changeset[:date]), |
|
|||
118 | :message => changeset[:description], |
|
|||
119 | :paths => changeset[:files].to_s.split.collect{|path| {:action => 'X', :path => "/#{path}"}} |
|
|||
120 | }) |
|
|||
121 | end |
|
109 | end | |
122 | return nil if $? && $?.exitstatus != 0 |
|
110 | return nil if $? && $?.exitstatus != 0 | |
123 | revisions |
|
111 | revisions | |
@@ -171,6 +159,47 module Redmine | |||||
171 | return nil if $? && $?.exitstatus != 0 |
|
159 | return nil if $? && $?.exitstatus != 0 | |
172 | blame |
|
160 | blame | |
173 | end |
|
161 | end | |
|
162 | ||||
|
163 | private | |||
|
164 | ||||
|
165 | # Builds a revision objet from the changeset returned by hg command | |||
|
166 | def build_revision_from_changeset(changeset) | |||
|
167 | rev_id = changeset[:changeset].to_s.split(':').first.to_i | |||
|
168 | ||||
|
169 | # Changes | |||
|
170 | paths = (rev_id == 0) ? | |||
|
171 | # Can't get changes for revision 0 with hg status | |||
|
172 | changeset[:files].to_s.split.collect{|path| {:action => 'A', :path => "/#{path}"}} : | |||
|
173 | status(rev_id) | |||
|
174 | ||||
|
175 | Revision.new({:identifier => rev_id, | |||
|
176 | :scmid => changeset[:changeset].to_s.split(':').last, | |||
|
177 | :author => changeset[:user], | |||
|
178 | :time => Time.parse(changeset[:date]), | |||
|
179 | :message => changeset[:description], | |||
|
180 | :paths => paths | |||
|
181 | }) | |||
|
182 | end | |||
|
183 | ||||
|
184 | # Returns the file changes for a given revision | |||
|
185 | def status(rev_id) | |||
|
186 | cmd = "#{HG_BIN} -R #{target('')} status --rev #{rev_id.to_i - 1}:#{rev_id.to_i}" | |||
|
187 | result = [] | |||
|
188 | shellout(cmd) do |io| | |||
|
189 | io.each_line do |line| | |||
|
190 | action, file = line.chomp.split | |||
|
191 | next unless action && file | |||
|
192 | file.gsub!("\\", "/") | |||
|
193 | case action | |||
|
194 | when 'R' | |||
|
195 | result << { :action => 'D' , :path => "/#{file}" } | |||
|
196 | else | |||
|
197 | result << { :action => action, :path => "/#{file}" } | |||
|
198 | end | |||
|
199 | end | |||
|
200 | end | |||
|
201 | result | |||
|
202 | end | |||
174 | end |
|
203 | end | |
175 | end |
|
204 | end | |
176 | end |
|
205 | end |
General Comments 0
You need to be logged in to leave comments.
Login now