summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-29 10:54:24 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-29 10:54:24 +0000
commit1bb51f743a3568dd8714233e83500bd7ff4feda8 (patch)
treec312194d398c15fb94e88089820c142e7512ace3
parent85858cebe64ab4ec404e1db2220b0cdfb7c5d32f (diff)
downloadredmine-1bb51f743a3568dd8714233e83500bd7ff4feda8.tar.gz
redmine-1bb51f743a3568dd8714233e83500bd7ff4feda8.zip
Fixed: migrate_from_trac doesn't import timestamps of wiki and tickets (patch #882 by Andreas Neuhaus slightly edited).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1302 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--lib/tasks/migrate_from_trac.rake28
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/tasks/migrate_from_trac.rake b/lib/tasks/migrate_from_trac.rake
index 996a5f937..7fe1f09ac 100644
--- a/lib/tasks/migrate_from_trac.rake
+++ b/lib/tasks/migrate_from_trac.rake
@@ -68,7 +68,22 @@ namespace :redmine do
ROLE_MAPPING = {'admin' => manager_role,
'developer' => developer_role
}
-
+
+ class ::Time
+ class << self
+ alias :real_now :now
+ def now
+ real_now - @fake_diff.to_i
+ end
+ def fake(time)
+ @fake_diff = real_now - time
+ res = yield
+ @fake_diff = 0
+ res
+ end
+ end
+ end
+
class TracComponent < ActiveRecord::Base
set_table_name :component
end
@@ -141,6 +156,7 @@ namespace :redmine do
end
def time; Time.at(read_attribute(:time)) end
+ def changetime; Time.at(read_attribute(:changetime)) end
end
class TracTicketChange < ActiveRecord::Base
@@ -167,6 +183,8 @@ namespace :redmine do
# Hides readonly Trac field to prevent clash with AR readonly? method (Rails 2.0)
super.select {|column| column.name.to_s != 'readonly'}
end
+
+ def time; Time.at(read_attribute(:time)) end
end
class TracPermission < ActiveRecord::Base
@@ -345,14 +363,14 @@ namespace :redmine do
i.tracker = TRACKER_MAPPING[ticket.ticket_type] || DEFAULT_TRACKER
i.custom_values << CustomValue.new(:custom_field => custom_field_map['resolution'], :value => ticket.resolution) unless ticket.resolution.blank?
i.id = ticket.id unless Issue.exists?(ticket.id)
- next unless i.save
+ next unless Time.fake(ticket.changetime) { i.save }
TICKET_MAP[ticket.id] = i.id
migrated_tickets += 1
# Owner
unless ticket.owner.blank?
i.assigned_to = find_or_create_user(ticket.owner, true)
- i.save
+ Time.fake(ticket.changetime) { i.save }
end
# Comments and status/resolution changes
@@ -426,7 +444,7 @@ namespace :redmine do
p.content.text = page.text
p.content.author = find_or_create_user(page.author) unless page.author.blank? || page.author == 'trac'
p.content.comments = page.comment
- p.new_record? ? p.save : p.content.save
+ Time.fake(page.time) { p.new_record? ? p.save : p.content.save }
next if p.content.new_record?
migrated_wiki_edits += 1
@@ -446,7 +464,7 @@ namespace :redmine do
wiki.reload
wiki.pages.each do |page|
page.content.text = convert_wiki_text(page.content.text)
- page.content.save
+ Time.fake(page.content.updated_on) { page.content.save }
end
end
puts