Project

General

Profile

Patch #14593 » migrate_from_trac.rake.patch.2.txt

Craig Rodrigues, 2013-10-13 06:28

 
1
Index: migrate_from_trac.rake
2
===================================================================
3
--- migrate_from_trac.rake	(revision 12202)
4
+++ migrate_from_trac.rake	(working copy)
5
@@ -261,7 +261,13 @@
6
           u.password = 'trac'
7
           u.admin = true if TracPermission.find_by_username_and_action(username, 'admin')
8
           # finally, a default user is used if the new user is not valid
9
-          u = User.first unless u.save
10
+          unless u.save
11
+             u.errors.full_messages.each do |msg|
12
+               print "\nERROR: ",msg,"\n"
13
+             end
14
+             print "ERROR: Skipping user.\n"
15
+             u = User.first
16
+          end
17
         end
18
         # Make sure user is a member of the project
19
         if project_member && !u.member_of?(@target_project)
20
@@ -399,7 +405,13 @@
21
         STDOUT.flush
22
           c = IssueCategory.new :project => @target_project,
23
                                 :name => encode(component.name[0, limit_for(IssueCategory, 'name')])
24
-        next unless c.save
25
+        unless c.save
26
+          c.errors.full_messages.each do |msg|
27
+            print "\nERROR: ",msg,"\n"
28
+          end
29
+          print "Error: Skipping category.\n"
30
+          next
31
+        end
32
         issues_category_map[component.name] = c
33
         migrated_components += 1
34
         end
35
@@ -417,7 +429,12 @@
36
           p.content.text = milestone.description.to_s
37
           p.content.author = find_or_create_user('trac')
38
           p.content.comments = 'Milestone'
39
-          p.save
40
+          unless p.save
41
+            p.errors.full_messages.each do |msg|
42
+              print "\nERROR: ",msg,"\n"
43
+            end
44
+            print "ERROR: Error saving wiki page.\n"
45
+          end
46
 
47
           v = Version.new :project => @target_project,
48
                           :name => encode(milestone.name[0, limit_for(Version, 'name')]),
49
@@ -425,7 +442,13 @@
50
                           :wiki_page_title => milestone.name.to_s,
51
                           :effective_date => milestone.completed
52
 
53
-          next unless v.save
54
+          unless v.save
55
+            v.errors.full_messages.each do |msg|
56
+              print "\nERROR: ",msg,"\n"
57
+            end
58
+            print "ERROR: Skipping version.\n"
59
+            next
60
+          end
61
           version_map[milestone.name] = v
62
           migrated_milestones += 1
63
         end
64
@@ -589,6 +612,11 @@
65
             page.content.text = convert_wiki_text(page.content.text)
66
             Time.fake(page.content.updated_on) { page.content.save }
67
           end
68
+        else
69
+          wiki.errors.full_messages.each do |msg|
70
+            print "\nERROR: ",msg,"\n"
71
+          end
72
+          print "ERROR: Error saving wiki.\n"
73
         end
74
         puts
75
 
(2-2/2)