tags:

views:

109

answers:

2

I have code in an svn repository, call it repository A. Now say that I need to move the contents to repository B, but repository B has already been active for a while for other projects. Is it possible to move a particular directory from repository A to repository B, preserving the file history? Normally, to migrate an entire repository to a new server, I would do:

svnadmin dump -r 0:179 rep_a > rep_a.dump
svnadmin create rep_b
svnadmin load rep_b < rep_a.dump

However, this acts on the whole repository and assumes repository B is empty to start with (I think). I can of course export the directory in question and import it into repository B, but I lose the version history.

Is there an easy way to move a particular directory from A to B without losing the version history?

A: 

Look at Filtering Repository History in the SVN book.

sbi
+3  A: 

Let's say you want to copy directory trunk/project of rep_a into rep_b, you have to use this command:

svnadmin dump rep_a | svndumpfilter include trunk/project | svnadmin load rep_b

The revisions related to rep_a will be added to the history of rep_b.

Be careful with that and make a backup before, of course. Also, it can be tricky if you have common directories, then you will have to remove directory creations from the dump (to avoid creating the same directories twice).

RedGlyph
Thanks! So I presume the path to the directory is the same, so trunk/project on rep_a becomes trunk/project on rep_b? Just in case, is there an easy way to change the path during the migration? So that for example trunk/project becomes trunk_import/project?
astrofrog
There is an option `svnadmin load --parent-dir`. If you need something more complex, I suggest you have a look at this old Perl script (if you have a Perl interpreter): http://www.coelho.net/svn-merge-repos.html. There is another one in Python, but I have never used it except to make a few simple tests: http://www.orcaware.com/svn/wiki/Svnmerge.py
RedGlyph