##// END OF EJS Templates
Mercurial: Get proper file action on revision (#983)....
Jean-Philippe Lang -
r1317:db7f890030b8
parent child
Show More
@@ -88,13 +88,7 module Redmine
88 88 value = $2
89 89 if parsing_descr && line_feeds > 1
90 90 parsing_descr = false
91 revisions << Revision.new({:identifier => changeset[:changeset].split(':').first.to_i,
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 })
91 revisions << build_revision_from_changeset(changeset)
98 92 changeset = {}
99 93 end
100 94 if !parsing_descr
@@ -111,13 +105,7 module Redmine
111 105 line_feeds += 1 if line.chomp.empty?
112 106 end
113 107 end
114 revisions << Revision.new({:identifier => changeset[:changeset].split(':').first.to_i,
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 })
108 revisions << build_revision_from_changeset(changeset)
121 109 end
122 110 return nil if $? && $?.exitstatus != 0
123 111 revisions
@@ -171,6 +159,47 module Redmine
171 159 return nil if $? && $?.exitstatus != 0
172 160 blame
173 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 203 end
175 204 end
176 205 end
General Comments 0
You need to be logged in to leave comments. Login now