scm: bazaar: convert path encoding from @path_encoding to UTF-8 at adapter entries method (#11834)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10418 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2012-09-17 23:46:53 +00:00
parent a3ae06921d
commit a701bd5fbd
1 changed files with 8 additions and 4 deletions

View File

@ -91,13 +91,17 @@ module Redmine
cmd_args << "-r#{identifier.to_i}" cmd_args << "-r#{identifier.to_i}"
cmd_args << bzr_target(path) cmd_args << bzr_target(path)
scm_cmd(*cmd_args) do |io| scm_cmd(*cmd_args) do |io|
prefix = "#{url}/#{path}".gsub('\\', '/') prefix_utf8 = "#{url}/#{path}".gsub('\\', '/')
logger.debug "PREFIX: #{prefix}" logger.debug "PREFIX: #{prefix_utf8}"
prefix = scm_iconv(@path_encoding, 'UTF-8', prefix_utf8)
prefix.force_encoding('ASCII-8BIT') if prefix.respond_to?(:force_encoding)
re = %r{^V\s+(#{Regexp.escape(prefix)})?(\/?)([^\/]+)(\/?)\s+(\S+)\r?$} re = %r{^V\s+(#{Regexp.escape(prefix)})?(\/?)([^\/]+)(\/?)\s+(\S+)\r?$}
io.each_line do |line| io.each_line do |line|
next unless line =~ re next unless line =~ re
entries << Entry.new({:name => $3.strip, name_locale = $3.strip
:path => ((path.empty? ? "" : "#{path}/") + $3.strip), name = scm_iconv('UTF-8', @path_encoding, name_locale)
entries << Entry.new({:name => name,
:path => ((path.empty? ? "" : "#{path}/") + name),
:kind => ($4.blank? ? 'file' : 'dir'), :kind => ($4.blank? ? 'file' : 'dir'),
:size => nil, :size => nil,
:lastrev => Revision.new(:revision => $5.strip) :lastrev => Revision.new(:revision => $5.strip)