Improved Trac-Importer with subversion repository migration
I've spent some time improving the trac import script and also to provide a tool to also migrate the associated Subversion repository.The following changes were done to the trac migration process:
- The original trac ticket id is stored in a new custom field named TracID
- The modification of all Wiki-like texts is done after all tickets have been migrated as only then all newly assigned ticket ids are defined.
- Numbered lists are now supported
- Source links are done the same way as milestones are treated
- The modification of any Wiki-like texts (Milestone descriptions, Issue descriptions, Issue change notes, and Wiki pages) was added
In addition to the migration of the trac repository, we had to modify the associated svn repository since the checkin comments were also having references to tickets in the commit messages. The new rake task redmine:migrate_svn_commits can be run after the trac repository has been migrated. The new task is recreating the association between trac ticket id and newly created redmine ticket id. Then all commit messages in the provided repository are extracted and converted with the same wiki translation during the trac migration. All ticket references are modified to point to the newly assigned redmine ticket identifiers.
Running the tool gives you the following output:
rake redmine:migrate_svn_commits RAILS_ENV="production" WARNING: all commit messages with references to trac pages will be modified Are you sure you want to continue ? [y/N] y Subversion repository url : http://svn.server.dom/project Subversion repository username : user Subversion repository password : secret Redmine project identifier : project-id
In order for the script to succeed, the subversion repository must allow modification
of revision properties. This can be accomplished by enabling the pre-revprop-change hook script
that returns 0 to the caller. The script can be as simple as the following:
A Windows pre-revprop-change.cmd:
...or a unix executable script pre-revprop-change
#!/bin/sh exit 0
#1 Updated by Thomas Recloux about 11 years ago
What a wonderful Patch !
I successfully used your modified script on a 0.8.4 redmine.
Thanks a lot.
I just had to modify some details :
- Line 894, the constructor of the SvnExtendedAdapter has ony got four parameters, I removed the three last parameters :
@scm ||= SvnExtendedAdapter.new @@svn_url, @@svn_url, @@svn_username, @@svn_password
- Redmine needs a space between the keyword "refs" and the issue number (#1234) in subversion commit messages. I added four substitutions in the "convert_wiki_text_mapping" method :
text = text.gsub("refs#", "refs #")
text = text.gsub("Refs#", "refs #")
text = text.gsub("REFS#", "refs #")
text = text.gsub("ref#" , "refs #")
I'm a beginner in Ruby and I hope this not too ugly :-)
#2 Updated by Marcel Nadje almost 11 years ago
Thanx for the nice path. The only problem I have is the false converting german umlauts. After running redmine:migrate_svn_commits alle ticket refs in log massages are successfully migrated but the german umlauts ä, ö, ü and ß are broken. How can I convert the germa umlauts?