Project

General

Profile

Defect #834 » cvs.diff

Francis Chong, 2008-05-05 04:58

View differences:

/Users/siuying/Documents/workspace/redmine-trunk/app/models/repository/cvs.rb (working copy)
require 'redmine/scm/adapters/cvs_adapter'
require 'digest/sha1'
require 'iconv'
class Repository::Cvs < Repository
validates_presence_of :url, :root_url
......
cs = changesets.find(:first, :conditions=>{
:committed_on=>revision.time-time_delta..revision.time+time_delta,
:committer=>revision.author,
:comments=>revision.message
:comments=>fix_corrupt_encode(revision.message)
})
# create a new changeset....
......
:revision => "_#{tmp_rev_num}",
:committer => revision.author,
:committed_on => revision.time,
:comments => revision.message)
:comments => fix_corrupt_encode(revision.message))
tmp_rev_num += 1
end
......
end
private
def fix_corrupt_encode(untrusted_string)
Iconv.new('UTF-8//IGNORE', 'UTF-8').iconv(untrusted_string + ' ')[0..-2]
end
# Returns the next revision number to assign to a CVS changeset
def next_revision_number
......
@current_revision_number ||= (connection.select_values("SELECT revision FROM #{Changeset.table_name} WHERE repository_id = #{id} AND revision NOT LIKE '_%'").collect(&:to_i).max || 0)
@current_revision_number += 1
end
end
end
(1-1/2)