Project

General

Profile

Feature #1735 ยป cvs_encoding.patch

Each project encoding. For r1794. - Leonid Myravyev, 2008-09-09 22:06

View differences:

app/helpers/repositories_helper.rb (working copy)
78 78
      content_tag('p', form.password_field(:password, :size => 30, :name => 'ignore',
79 79
                                           :value => ((repository.new_record? || repository.password.blank?) ? '' : ('x'*15)),
80 80
                                           :onfocus => "this.value=''; this.name='repository[password]';",
81
                                           :onchange => "this.name='repository[password]';"))
81
                                           :onchange => "this.name='repository[password]';")) +
82
      content_tag('p', form.text_field(:encoding, :size => 30, :disabled => (repository && !repository.root_url.blank?)))
82 83
  end
83 84

  
84 85
  def darcs_field_tags(form, repository)
85
      content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?)))
86
      content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?))) +
87
      content_tag('p', form.text_field(:encoding, :size => 30,  :disabled => ( repository && !repository.new_record?)))
86 88
  end
87 89
  
88 90
  def mercurial_field_tags(form, repository)
89
      content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)))
91
      content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?))) +
92
      content_tag('p', form.text_field(:encoding, :size => 30,   :disabled => (repository && !repository.root_url.blank?)))
90 93
  end
91 94

  
92 95
  def git_field_tags(form, repository)
93
      content_tag('p', form.text_field(:url, :label => 'Path to .git directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)))
96
      content_tag('p', form.text_field(:url, :label => 'Path to .git directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?))) +
97
      content_tag('p', form.text_field(:encoding, :size => 30,   :disabled => (repository && !repository.root_url.blank?)))
94 98
  end
95 99

  
96 100
  def cvs_field_tags(form, repository)
97 101
      content_tag('p', form.text_field(:root_url, :label => 'CVSROOT', :size => 60, :required => true, :disabled => !repository.new_record?)) +
98
      content_tag('p', form.text_field(:url, :label => 'Module', :size => 30, :required => true, :disabled => !repository.new_record?))
102
      content_tag('p', form.text_field(:url, :label => 'Module', :size => 30, :required => true, :disabled => !repository.new_record?)) +
103
      content_tag('p', form.text_field(:encoding, :size => 30,   :disabled => (repository && !repository.new_record?)))
99 104
  end
100 105

  
101 106
  def bazaar_field_tags(form, repository)
102
      content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?)))
107
      content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?))) +
108
      content_tag('p', form.text_field(:encoding, :size => 30,   :disabled => (repository && !repository.new_record?)))
103 109
  end
104 110
  
105 111
  def filesystem_field_tags(form, repository)
106
    content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)))
112
    content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?))) +
113
    content_tag('p', form.text_field(:encoding, :size => 30,   :disabled => (repository && !repository.root_url.blank?)))
107 114
  end
108 115
end
app/models/repository/subversion.rb (working copy)
19 19

  
20 20
class Repository::Subversion < Repository
21 21
  attr_protected :root_url
22
  validates_presence_of :url
22
  validates_presence_of :url, :encoding
23 23
  validates_format_of :url, :with => /^(http|https|svn|svn\+ssh|file):\/\/.+/i
24 24

  
25 25
  def scm_adapter
app/models/repository/bazaar.rb (working copy)
19 19

  
20 20
class Repository::Bazaar < Repository
21 21
  attr_protected :root_url
22
  validates_presence_of :url
22
  validates_presence_of :url, :encoding
23 23

  
24 24
  def scm_adapter
25 25
    Redmine::Scm::Adapters::BazaarAdapter
app/models/repository/git.rb (working copy)
19 19

  
20 20
class Repository::Git < Repository
21 21
  attr_protected :root_url
22
  validates_presence_of :url
22
  validates_presence_of :url, :encoding
23 23

  
24 24
  def scm_adapter
25 25
    Redmine::Scm::Adapters::GitAdapter
app/models/repository/mercurial.rb (working copy)
19 19

  
20 20
class Repository::Mercurial < Repository
21 21
  attr_protected :root_url
22
  validates_presence_of :url
22
  validates_presence_of :url, :encoding
23 23

  
24 24
  def scm_adapter
25 25
    Redmine::Scm::Adapters::MercurialAdapter
app/models/repository/filesystem.rb (working copy)
22 22

  
23 23
class Repository::Filesystem < Repository
24 24
  attr_protected :root_url
25
  validates_presence_of :url
25
  validates_presence_of :url, :encoding
26 26

  
27 27
  def scm_adapter
28 28
    Redmine::Scm::Adapters::FilesystemAdapter
app/models/repository/cvs.rb (working copy)
19 19
require 'digest/sha1'
20 20

  
21 21
class Repository::Cvs < Repository
22
  validates_presence_of :url, :root_url
22
  validates_presence_of :url, :root_url, :encoding
23 23

  
24 24
  def scm_adapter
25 25
    Redmine::Scm::Adapters::CvsAdapter
app/models/repository/darcs.rb (working copy)
18 18
require 'redmine/scm/adapters/darcs_adapter'
19 19

  
20 20
class Repository::Darcs < Repository
21
  validates_presence_of :url
21
  validates_presence_of :url, :encoding
22 22

  
23 23
  def scm_adapter
24 24
    Redmine::Scm::Adapters::DarcsAdapter
app/models/repository.rb (working copy)
31 31
  def url=(arg)
32 32
    write_attribute(:url, arg ? arg.to_s.strip : nil)
33 33
  end
34
  
34

  
35
	def encoding=(arg)
36
    write_attribute(:encoding, arg ? arg.to_s.strip : nil)
37
  end
38

  
39

  
35 40
  # Removes leading and trailing whitespace
36 41
  def root_url=(arg)
37 42
    write_attribute(:root_url, arg ? arg.to_s.strip : nil)
38 43
  end
39 44

  
40 45
  def scm
41
    @scm ||= self.scm_adapter.new url, root_url, login, password
46
    @scm ||= self.scm_adapter.new url, root_url, login, password, encoding
42 47
    update_attribute(:root_url, @scm.root_url) if root_url.blank?
43 48
    @scm
44 49
  end
......
129 134
    # Strips url and root_url
130 135
    url.strip!
131 136
    root_url.strip!
137
    encoding.strip!
132 138
    true
133 139
  end
134 140
  
app/controllers/application.rb (working copy)
33 33
  def current_role
34 34
    @current_role ||= User.current.role_for_project(@project)
35 35
  end
36
  
36
 
37

  
37 38
  def user_setup
38 39
    # Check the settings cache for each request
39 40
    Setting.check_cache
lib/redmine/scm/adapters/abstract_adapter.rb (working copy)
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 17

  
18
require 'iconv'
18 19
require 'cgi'
19 20

  
20 21
module Redmine
......
47 48
          end
48 49
        end
49 50
                
50
        def initialize(url, root_url=nil, login=nil, password=nil)
51
        def initialize(url, root_url=nil, login=nil, password=nil, encoding=nil)
51 52
          @url = url
52 53
          @login = login if login && !login.empty?
53 54
          @password = (password || "") if @login
54 55
          @root_url = root_url.blank? ? retrieve_root_url : root_url
56
          @encoding = encoding.blank? ? "UTF-8" : encoding 
55 57
        end
56
        
58
       
59
				def to_utf(str)
60
					if encoding != nil and str != nil and encoding != "UTF-8" 
61
							logger.debug "Encoding, from: #{encoding}"
62
							return Iconv.conv("UTF-8", encoding, str)
63
				  end
64
					logger.debug "Don't encoding, enc: #{encoding}"
65
					return str
66

  
67
				end
68

  
57 69
        def adapter_name
58 70
          'Abstract'
59 71
        end
......
69 81
        def root_url
70 82
          @root_url
71 83
        end
72
      
84
     
85
  			def encoding
86
					@encoding
87
				end
88

  
73 89
        def url
74 90
          @url
75 91
        end
lib/redmine/scm/adapters/cvs_adapter.rb (working copy)
30 30
        #  root_url -> the good old, sometimes damned, CVSROOT
31 31
        #  login -> unnecessary
32 32
        #  password -> unnecessary too
33
        def initialize(url, root_url=nil, login=nil, password=nil)
33
        #  encoding -> unnecessary too
34
        def initialize(url, root_url=nil, login=nil, password=nil, encoding="UTF-8")
34 35
          @url = url
35 36
          @login = login if login && !login.empty?
36 37
          @password = (password || "") if @login
38
					@encoding = encoding
37 39
          #TODO: better Exception here (IllegalArgumentException)
38 40
          raise CommandFailed if root_url.blank?
39 41
          @root_url = root_url
......
220 222
                  #                  version.line_minus = 0     
221 223
                  #                end              
222 224
                else            
223
                  commit_log << line unless line =~ /^\*\*\* empty log message \*\*\*/
225
                  commit_log << to_utf( (line unless line =~ /^\*\*\* empty log message \*\*\*/) )
224 226
                end 
225 227
              end 
226 228
            end
    (1-1/1)