Sie sind hier: Startseite / Blog / Convert SVN-Repo directly to git or hg (no dump-files needes)

Convert SVN-Repo directly to git or hg (no dump-files needes)

Origo, where I'm hosting my open-source software up to now, is closing end of this month. So I need to move these projects somewhere else. I take the chance for migrating the subversion repositories to git. Here is how.

If you are going to convert your repo to git or mercurial, you can use Eric S. Raymonds excellent `reposurgeon` tool. The current development version can read directly form subversion repositories. It's recommended to create a local mirror first. A tool called `svnpull` for pulling the SVN repo into a local mirror is provided.

Homepage: http://www.catb.org/esr/reposurgeon/
Development version: https://gitorious.org/reposurgeon/reposurgeon

Here is an example of a simple conversion of a simple repository:

PROJECT=ssl-audit
svnrepo=https://svn.origo.ethz.ch/$PROJECT
gitrepo=/tmp/$PROJECT-git

cd /tmp
repopuller $svnrepo

reposurgeon <<EOF
read /tmp/$PROJECT-mirror
prefer git
edit
references lift
rebuild $gitrepo
EOF

Recommended Cleanup Actions

I recommend doing at least these cleanup action (within reposurgeon) when converting a repo:

  • Add an authormap to get nice author names.
  • Clean up the most uggly commit messages. (Do not wast too much time for this. I did, when converting PyInstallers repo, and the results are nor worth the effort.)
  • Lift references (e.g. revision numbers to a time-stamp)

I recommend reading at least these sections in the man-page `reposurgeon.1`:

  • Artifacts removal
  • Reference Lifting
  • Working with Subversion

For more insights you may want to read Erics DVCS Migration Guide and have a look at my work done for the PyInstaller repo-conversion. You may also want to read my comments about why I'm now preferring git over mercurial.

[Edit 2014-03-31: Fix typo in script, use repopuller]