Mercurial > hg > soundsoftware-site
diff lib/redmine/scm/adapters/bazaar_adapter.rb @ 1115:433d4f72a19b redmine-2.2
Update to Redmine SVN revision 11137 on 2.2-stable branch
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 12:01:42 +0000 |
parents | cbb26bc654de |
children | 51d7f3e06556 622f24f53b42 |
line wrap: on
line diff
--- a/lib/redmine/scm/adapters/bazaar_adapter.rb Wed Jun 27 14:54:18 2012 +0100 +++ b/lib/redmine/scm/adapters/bazaar_adapter.rb Mon Jan 07 12:01:42 2013 +0000 @@ -1,5 +1,5 @@ # Redmine - project management software -# Copyright (C) 2006-2011 Jean-Philippe Lang +# Copyright (C) 2006-2012 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -57,6 +57,17 @@ end end + def initialize(url, root_url=nil, login=nil, password=nil, path_encoding=nil) + @url = url + @root_url = url + @path_encoding = 'UTF-8' + # do not call *super* for non ASCII repository path + end + + def bzr_path_encodig=(encoding) + @path_encoding = encoding + end + # Get info about the repository def info cmd_args = %w|revno| @@ -86,13 +97,17 @@ cmd_args << "-r#{identifier.to_i}" cmd_args << bzr_target(path) scm_cmd(*cmd_args) do |io| - prefix = "#{url}/#{path}".gsub('\\', '/') - logger.debug "PREFIX: #{prefix}" + prefix_utf8 = "#{url}/#{path}".gsub('\\', '/') + 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?$} io.each_line do |line| next unless line =~ re - entries << Entry.new({:name => $3.strip, - :path => ((path.empty? ? "" : "#{path}/") + $3.strip), + name_locale = $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'), :size => nil, :lastrev => Revision.new(:revision => $5.strip) @@ -143,7 +158,8 @@ revision.message << "#{$1}\n" else if $1 =~ /^(.*)\s+(\S+)$/ - path = $1.strip + path_locale = $1.strip + path = scm_iconv('UTF-8', @path_encoding, path_locale) revid = $2 case parsing when 'added' @@ -154,7 +170,10 @@ revision.paths << {:action => 'D', :path => "/#{path}", :revision => revid} when 'renamed' new_path = path.split('=>').last - revision.paths << {:action => 'M', :path => "/#{new_path.strip}", :revision => revid} if new_path + if new_path + revision.paths << {:action => 'M', :path => "/#{new_path.strip}", + :revision => revid} + end end end end @@ -280,8 +299,13 @@ def scm_cmd(*args, &block) full_args = [] full_args += args + full_args_locale = [] + full_args.map do |e| + full_args_locale << scm_iconv(@path_encoding, 'UTF-8', e) + end ret = shellout( - self.class.sq_bin + ' ' + full_args.map { |e| shell_quote e.to_s }.join(' '), + self.class.sq_bin + ' ' + + full_args_locale.map { |e| shell_quote e.to_s }.join(' '), &block ) if $? && $?.exitstatus != 0 @@ -294,8 +318,13 @@ def scm_cmd_no_raise(*args, &block) full_args = [] full_args += args + full_args_locale = [] + full_args.map do |e| + full_args_locale << scm_iconv(@path_encoding, 'UTF-8', e) + end ret = shellout( - self.class.sq_bin + ' ' + full_args.map { |e| shell_quote e.to_s }.join(' '), + self.class.sq_bin + ' ' + + full_args_locale.map { |e| shell_quote e.to_s }.join(' '), &block ) ret