Importing an svn repository into mercurial
Recently I’ve been forking Subversion (SVN) repositories by converting them to
mercurial repositories and uploading them to
Bitbucket. It’s fairly easy with the
Mercurial convert
extension. Convert
is distributed with Mercurial so if you have a recent version all you
should have to do is put the following in your hgrc.
[extensions]
hgext.convert=
Converting a repository over HTTP by running convert using the repository URL
can be very slow so it’s generally much faster to sync the SVN repository
locally and then convert it to Mercurial. First you need to use
svnsync to copy the
repository.
$ svnadmin create foomirror
$ echo '#!/bin/sh' > foomirror/hooks/pre-revprop-change # make insecure dummy hook
$ chmod +x foomirror/hooks/pre-revprop-change
$ svnsync init --username svnsync file://`pwd`/foomirror https://foo.svn.sourceforge.net/svnroot/foo
Copied properties for revision 0.
$ svnsync sync file://`pwd`/foomirror
Committed revision 1.
Copied properties for revision 1.
Committed revision 2.
Copied properties for revision 2.
...
Once the mirror is set up you can run hg convert on the local mirror.
This turns out to be much faster than trying to convert the SVN
repository remotely.
$ hg convert foomirror # convert directly from repo mirror to foomirror-hg
...