Project

General

Profile

Actions

Patch #2748

open

Improved Trac-Importer with subversion repository migration

Added by Mathias Kühn about 15 years ago. Updated about 14 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Importers
Target version:
-
Start date:
2009-02-13
Due date:
% Done:

0%

Estimated time:

Description

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:

exit 0

...or a unix executable script pre-revprop-change

#!/bin/sh
exit 0


Files

migrate_from_trac.rake (38.5 KB) migrate_from_trac.rake Modified importer Mathias Kühn, 2009-02-13 23:22
Actions #1

Updated by Thomas Recloux over 14 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 :-)

Actions #2

Updated by Marcel Nadje over 14 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?

Actions #3

Updated by Marcel Nadje over 14 years ago

Here is my solution. To enable correct german umlaut handling insert before the line
scm.set_message(@svn_url, commit.revision, newText)
the line
newText = Iconv.conv('CP1252', 'UTF-8', newText)

Actions #4

Updated by Bryce Nordgren about 14 years ago

How do I vote for this one? I just spent an hour or so manually converting my numbered lists from trac! +1 +1 +1

Actions

Also available in: Atom PDF