summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-04-06 12:00:11 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-04-06 12:00:11 +0000
commitdb7f890030b8138fc12d5debcdc66bf1b1e3861b (patch)
treebdbb9e2c844c4a6c748db155ae67e031f963f672 /lib
parenta7ca01a8de609cb1b0453d615ee0a90c3da1192d (diff)
downloadredmine-db7f890030b8138fc12d5debcdc66bf1b1e3861b.tar.gz
redmine-db7f890030b8138fc12d5debcdc66bf1b1e3861b.zip
Mercurial: Get proper file action on revision (#983).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1332 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/scm/adapters/mercurial_adapter.rb57
1 files changed, 43 insertions, 14 deletions
diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb
index ff52ab893..b92c88646 100644
--- a/lib/redmine/scm/adapters/mercurial_adapter.rb
+++ b/lib/redmine/scm/adapters/mercurial_adapter.rb
@@ -88,13 +88,7 @@ module Redmine
value = $2
if parsing_descr && line_feeds > 1
parsing_descr = false
- revisions << Revision.new({:identifier => changeset[:changeset].split(':').first.to_i,
- :scmid => changeset[:changeset].split(':').last,
- :author => changeset[:user],
- :time => Time.parse(changeset[:date]),
- :message => changeset[:description],
- :paths => changeset[:files].to_s.split.collect{|path| {:action => 'X', :path => "/#{path}"}}
- })
+ revisions << build_revision_from_changeset(changeset)
changeset = {}
end
if !parsing_descr
@@ -111,13 +105,7 @@ module Redmine
line_feeds += 1 if line.chomp.empty?
end
end
- revisions << Revision.new({:identifier => changeset[:changeset].split(':').first.to_i,
- :scmid => changeset[:changeset].split(':').last,
- :author => changeset[:user],
- :time => Time.parse(changeset[:date]),
- :message => changeset[:description],
- :paths => changeset[:files].to_s.split.collect{|path| {:action => 'X', :path => "/#{path}"}}
- })
+ revisions << build_revision_from_changeset(changeset)
end
return nil if $? && $?.exitstatus != 0
revisions
@@ -171,6 +159,47 @@ module Redmine
return nil if $? && $?.exitstatus != 0
blame
end
+
+ private
+
+ # Builds a revision objet from the changeset returned by hg command
+ def build_revision_from_changeset(changeset)
+ rev_id = changeset[:changeset].to_s.split(':').first.to_i
+
+ # Changes
+ paths = (rev_id == 0) ?
+ # Can't get changes for revision 0 with hg status
+ changeset[:files].to_s.split.collect{|path| {:action => 'A', :path => "/#{path}"}} :
+ status(rev_id)
+
+ Revision.new({:identifier => rev_id,
+ :scmid => changeset[:changeset].to_s.split(':').last,
+ :author => changeset[:user],
+ :time => Time.parse(changeset[:date]),
+ :message => changeset[:description],
+ :paths => paths
+ })
+ end
+
+ # Returns the file changes for a given revision
+ def status(rev_id)
+ cmd = "#{HG_BIN} -R #{target('')} status --rev #{rev_id.to_i - 1}:#{rev_id.to_i}"
+ result = []
+ shellout(cmd) do |io|
+ io.each_line do |line|
+ action, file = line.chomp.split
+ next unless action && file
+ file.gsub!("\\", "/")
+ case action
+ when 'R'
+ result << { :action => 'D' , :path => "/#{file}" }
+ else
+ result << { :action => action, :path => "/#{file}" }
+ end
+ end
+ end
+ result
+ end
end
end
end