Project

General

Profile

Defect #2664 » for-trunk-r4893-20110220.patch

Toshi MARUYAMA, 2011-02-20 15:59

View differences:

app/helpers/repositories_helper.rb
end
def mercurial_field_tags(form, repository)
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)))
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?))) +
content_tag('p', form.select(:path_encoding, [nil] + Setting::ENCODINGS,
:label => 'Path encoding'))
end
def git_field_tags(form, repository)
app/models/repository.rb
end
def scm
@scm ||= self.scm_adapter.new url, root_url, login, password
@scm ||= self.scm_adapter.new url, root_url,
login, password, path_encoding, nil
update_attribute(:root_url, @scm.root_url) if root_url.blank?
@scm
end
......
end
private
def before_save
# Strips url and root_url
url.strip!
lib/redmine/scm/adapters/abstract_adapter.rb
end
end
def initialize(url, root_url=nil, login=nil, password=nil)
def initialize(url, root_url=nil, login=nil, password=nil,
path_encoding=nil, log_encoding=nil)
@url = url
@login = login if login && !login.empty?
@password = (password || "") if @login
@root_url = root_url.blank? ? retrieve_root_url : root_url
......
@url = url
@login = login if login && !login.empty?
@password = (password || "") if @login
@root_url = root_url.blank? ? retrieve_root_url : root_url
@path_encoding = path_encoding || 'UTF-8'
end
......
end
def adapter_name
'Abstract'
end
......
def strip_credential(cmd)
self.class.strip_credential(cmd)
end
def scm_iconv(to, from, str)
return unless str
return str if to == from
begin
Iconv.conv(to, from, str)
rescue Iconv::Failure => err
raise CommandFailed, "failed to convert path from #{from} to #{to}. #{err}"
end
end
end
class Entries < Array
lib/redmine/scm/adapters/cvs_adapter.rb
# root_url -> the good old, sometimes damned, CVSROOT
# login -> unnecessary
# password -> unnecessary too
def initialize(url, root_url=nil, login=nil, password=nil)
def initialize(url, root_url=nil, login=nil, password=nil,
path_encoding=nil, log_encoding=nil)
@url = url
@login = login if login && !login.empty?
@password = (password || "") if @login
lib/redmine/scm/adapters/darcs_adapter.rb
end
end
def initialize(url, root_url=nil, login=nil, password=nil)
def initialize(url, root_url=nil, login=nil, password=nil,
path_encoding=nil, log_encoding=nil)
@url = url
@root_url = url
end
lib/redmine/scm/adapters/filesystem_adapter.rb
end
end
def initialize(url, root_url=nil, login=nil, password=nil)
def initialize(url, root_url=nil, login=nil, password=nil,
path_encoding=nil, log_encoding=nil)
@url = with_trailling_slash(url)
end
lib/redmine/scm/adapters/mercurial/redminehelper.py
ui.write('</manifest>\n')
def rhcat(ui, repo, file1, *pats, **opts):
return commands.cat(ui, repo, urllib.unquote(file1), *map(urllib.unquote, pats), **opts)
def rhdiff(ui, repo, *pats, **opts):
"""diff repository (or selected files)"""
change = opts.pop('change', None)
......
# This extension should be compatible with Mercurial 0.9.5.
# Note that Mercurial 0.9.5 doesn't have extensions.wrapfunction().
cmdtable = {
'rhcat': (rhcat,
[('r', 'rev', '', 'revision')],
'hg rhcat ([-r REV] ...) FILE...'),
'rhdiff': (rhdiff,
[('r', 'rev', [], 'revision'),
('c', 'change', '', 'change made by revision')],
lib/redmine/scm/adapters/mercurial_adapter.rb
private :summary
def entries(path=nil, identifier=nil)
p1 = scm_iconv(@path_encoding, 'UTF-8', path)
manifest = hg('rhmanifest', '-r', hgrev(identifier),
......
manifest = hg('rhmanifest', '-r', hgrev(identifier),
CGI.escape(without_leading_slash(path.to_s))) do |io|
CGI.escape(without_leading_slash(p1.to_s))) do |io|
begin
ActiveSupport::XmlMini.parse(io.read)['rhmanifest']['repository']['manifest']
rescue
......
entries = Entries.new
as_ary(manifest['dir']).each do |e|
n = CGI.unescape(e['name'])
n = scm_iconv('UTF-8', @path_encoding, CGI.unescape(e['name']))
p = "#{path_prefix}#{n}"
entries << Entry.new(:name => n, :path => p, :kind => 'dir')
end
as_ary(manifest['file']).each do |e|
......
p = "#{path_prefix}#{n}"
entries << Entry.new(:name => n, :path => p, :kind => 'dir')
end
as_ary(manifest['file']).each do |e|
n = CGI.unescape(e['name'])
n = scm_iconv('UTF-8', @path_encoding, CGI.unescape(e['name']))
p = "#{path_prefix}#{n}"
lr = Revision.new(:revision => e['revision'], :scmid => e['node'],
:identifier => e['node'],
......
cpmap = Hash[*cpalist.flatten]
paths = as_ary(le['paths']['path']).map do |e|
p = CGI.unescape(e['__content__'])
p = scm_iconv('UTF-8', @path_encoding, CGI.unescape(e['__content__']) )
{:action => e['action'], :path => with_leading_slash(p),
:from_path => (cpmap.member?(p) ? with_leading_slash(cpmap[p]) : nil),
:from_revision => (cpmap.member?(p) ? le['revision'] : nil)}
......
else
hg_args << '-c' << hgrev(identifier_from)
end
hg_args << CGI.escape(hgtarget(path)) unless path.blank?
unless path.blank?
p = scm_iconv(@path_encoding, 'UTF-8', path)
hg_args << CGI.escape(hgtarget(p))
end
diff = []
hg *hg_args do |io|
io.each_line do |line|
......
end
def cat(path, identifier=nil)
hg 'cat', '-r', hgrev(identifier), hgtarget(path) do |io|
p = CGI.escape(scm_iconv(@path_encoding, 'UTF-8', path))
hg 'rhcat', '-r', hgrev(identifier), hgtarget(p) do |io|
io.binmode
io.read
end
(7-7/8)