I don’t suppose many people will need this. But I found myself in a unique situation today, needing to transfer code from one Subversion repository to another. Preferably retaining the history of changesets and comments. Without access to the actual server repository.

So wrote up this little ruby script: svn2svn.rb

There’s nothing about it that needed it to be written in Ruby. Its just so. In fact I was too lazy to poke at SWIG to get proper Ruby APIs for SVN like Collaboa (aka Trac on Rails). I taken the easy way and used "system" and "popen" instead - blasphemous! The whole algorithm is hardly optimised as well, roughly:

  1. checkout each revision from source repository URL as r1, r2, r3, etc (the CVS equivalent will probably be "each log event")
  2. (create and) checkout the destination repository URL to a working directory
  3. for each revision, patch the diff -Naur output into the working directory and commit (includes svn add and svn remove where needed)

Step #1 will take quite a very long time, depending on connectivity. So, if you ever have the same need, use it at your own risk.

If its any assurance, it worked for me.