views:

6305

answers:

5

I have a "docs" folder in a Subversion repository named "project". I've come to the conclusion that it should really be kept under a separate Subversion repository named "project_docs". I'd like to move the "docs" folder (and all of it's revisions) to the "project_docs" repository. Is there any way to do this?

+1  A: 

I don't believe you can do it remotely (i.e., without a local copy). But this should work: svn export the folder from the original server, then svn add it to your new repo.

Like:

$ svn checkout svn://example.net/newrepo .
$ svn export svn://example.com/oldrepo/mydir ./mydir
$ svn add ./mydir; svn commit

Edit: D'oh, this drops the history. Use svnadmin as Samuel describes.

Peter Stone
this does not keep all the revisions, which he needs to preserve..
petr k.
However, you cannot keep the revisions without access to the repository itself. If you can only have a working copy, this is the best he can do.
Samuel
+2  A: 

This is discussed in the svn documentation. Check out the Repository Maintenance section on svndumpfilter... It specifically describes how to dump projects out of a central repository and move them into new, separate repositories.

Adam Bellaire
+29  A: 

If you have access the repository itself (not a working copy), you should be able to dump the current repository, filter it to only include information about the docs folder, and load it into the other repository.

Would be something like this:

svnadmin dump /svn/old_repos > ./repository.dump
svndumpfilter include path/to/docs --drop-empty-revs --renumber-revs --preserve-revprops < ./repository.dump > ./docs_only.dump
svnadmin load /svn/new_repos < ./docs_only.dump

Without access to the repository, you cannot maintain the revision history and you have to settle for copying the files into the new repository and committing.

Samuel
Nice example. Note that as stated in the documentation I linked to, this solution will re-number all of the revisions so that there are no "empties". Something to keep in mind if you reference the doc revisions anywhere else.
Adam Bellaire
I suggested the removal of empty revisions to avoid adding a bunch of empty revisions to the target repository, most likely confusing anyone that didn't know about the load. Since --preserve-revprops will keep the commit messages instead of the using the default one of loading.
Samuel
Thanks, I do have access to the repository - so I'll give this a shot.
leftend
Thanks for the answer. In case anyone needs to know, if you need more then one folder just put a space between them in the include list.Ex. ... include folderOne folderTwo
Robin Robinson
Renumbering revisions is probably a bad idea, as commit messages and issue tracking tools may refer to them
Wim Coenen
+8  A: 

svndumpfilter has a serious flaw - if a file or path was copied from a path you're filtering out to one you're filtering in, svndumpfilter won't be able to fill out the history and the job will fail.

You can use svndumpfilter2 if you experience this problem.

compie
A: 

What about if i have to delete the 'old_repo' after copied the particular content to the 'new_repo'..? Still is it possible to relocate to 'new_repo' with history?