diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-02-16 13:35:52 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-02-16 13:35:52 +0000 |
commit | 1f836a1d43a5f216955df3f156ce86cc857c9d92 (patch) | |
tree | 62142718b2a9052e607e1f9346978068d5217043 /lib | |
parent | 05210f18ed3194f149e755194d1e75f118d1bc9a (diff) | |
download | redmine-1f836a1d43a5f216955df3f156ce86cc857c9d92.tar.gz redmine-1f836a1d43a5f216955df3f156ce86cc857c9d92.zip |
scm: mercurial: rewrite MercurialAdapter#entries to show per-file change log and size (#3421, #4455).
Contributed by Yuya Nishihara.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4856 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/scm/adapters/mercurial_adapter.rb | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb index 93cfcf625..d64e6f8f5 100644 --- a/lib/redmine/scm/adapters/mercurial_adapter.rb +++ b/lib/redmine/scm/adapters/mercurial_adapter.rb @@ -93,28 +93,31 @@ module Redmine private :summary def entries(path=nil, identifier=nil) - path ||= '' + manifest = hg('rhmanifest', '-r', hgrev(identifier), + CGI.escape(without_leading_slash(path.to_s))) do |io| + ActiveSupport::XmlMini.parse(io.read)['rhmanifest']['repository']['manifest'] + end + path_prefix = path.blank? ? '' : with_trailling_slash(path) + entries = Entries.new - cmd = "#{self.class.sq_bin} -R #{target('')} --cwd #{target('')} locate" - cmd << " -r #{hgrev(identifier, true)}" - cmd << " " + shell_quote("path:#{path}") unless path.empty? - shellout(cmd) do |io| - io.each_line do |line| - # HG uses antislashs as separator on Windows - line = line.gsub(/\\/, "/") - if path.empty? or e = line.gsub!(%r{^#{with_trailling_slash(path)}},'') - e ||= line - e = e.chomp.split(%r{[\/\\]}) - entries << Entry.new({:name => e.first, - :path => (path.nil? or path.empty? ? e.first : "#{with_trailling_slash(path)}#{e.first}"), - :kind => (e.size > 1 ? 'dir' : 'file'), - :lastrev => Revision.new - }) unless e.empty? || entries.detect{|entry| entry.name == e.first} - end - end + as_ary(manifest['dir']).each do |e| + n = CGI.unescape(e['name']) + p = "#{path_prefix}#{n}" + entries << Entry.new(:name => n, :path => p, :kind => 'dir') end - return nil if $? && $?.exitstatus != 0 - entries.sort_by_name + + as_ary(manifest['file']).each do |e| + n = CGI.unescape(e['name']) + p = "#{path_prefix}#{n}" + lr = Revision.new(:revision => e['revision'], :scmid => e['node'], + :time => Time.at(e['time'].to_i)) + entries << Entry.new(:name => n, :path => p, :kind => 'file', + :size => e['size'].to_i, :lastrev => lr) + end + + entries + rescue HgCommandAborted + nil # means not found end def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}) |