Subversion: Move folder from one repository to another

A branch of a project went into a totally different direction. Therfor I wanted to move that specific folder into a new repository e.g.:

svn://myserver/repo1/branches/crazyrefactor/
svn://myserver/repo2/trunk/

To archive this there are several steps needed. You will need shell access to the server where the repository is located.

  1. Backup the source repository (creating a dump) and filter the specific source folder
  2. Create the new repository and the folder structure
  3. Import the dump file into the new repository
  4. Move the folder to trunk
Backup the source repository & filter the specific folder

Doing this two steps in one can improve the speed of the process alot, because the unneeded revisions will not be written to the disk. The tools svnadmin and svndumpfilter are being used:

svnadmin dump /var/svn/repo1 | svndumpfilter include /branches/crazyrefactor/ \
--drop-empty-revs --renumber-revs --preserve-revprops > ~/refactor.dump
Create the new repostory and the folder structure

The initial folder structure is done by checkout the repository and simply commit three new folders:

svnadmin create /var/svn/repo2
svn co file:///var/svn/repo2 ~/repo2
cd ~/repo2
mkdir trunk tags branches
svn add *
svn commit -m "Created initial structure"
Import the dump into the new repository

The imported project will be under the same path…

svnadmin load /var/svn/repo2 < ~/refactor.dump
Move the folder to trunk
svn move svn://localhost/repo2/branches/crazyrefactor svn://localhost/repo2/trunk \
-m "Moved imported branch into trunk"

What I’m missing here is an option to move the folder directly under the trunk folder. This would end in a cleaner history then. If you knows a way doing this it would be nice to here from you. 🙂

Commands taken from:

 

Leave a Comment