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:
- checkout each revision from source repository URL as r1, r2, r3, etc (the CVS equivalent will probably be "each log event")
- (create and) checkout the destination repository URL to a working directory
- 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.
Hi,
The link for script is broken.
Please, could you send me the script ?
igodpt@yahoo.com.br
thanks,
Paulo
Posted by: Paulo | April 09, 2008 at 03:20 AM
Hi Paulo,
The link is now fixed.
Posted by: choonkeat | April 09, 2008 at 11:03 AM
Thanks! I had a bit of trouble with binary files (patch kept failing). So, I replaced your system call to diff/patch with one which uses tar to copy the files and that fixed that. Here's the call:
system "tar -cf - -C #{newer} --exclude='\.svn' . | tar -xf - -C #{dest}"
Thanks again,
Mike
P.S.: It worked in Cygwin.
Posted by: Mike | May 07, 2009 at 03:29 AM
Hi Paulo,
Thanks for sharing the script.
I have been playing with it for a while. Use of svn_load_dirs gives same result as patching and is simpler
( with -message option to give comment, option available in trunk version of script).
There is big problem of the script, it does not track renaming, moving. So you will connection to history before renaming. I think it is better to use xml, which I am going to do.
It must be
Posted by: Gadolin | August 13, 2010 at 05:51 PM