Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I extract a subtree from my SVN repository into a new one?

We have a Subversion repository with one directory that is:

  • Not really in need of revision control beyond the capabilities of RCS
  • Not versioned in conjunction with anything else in the repository
  • Modified about six times as often as the rest of the repository

Although I know that high revision numbers aren't a problem, nonetheless I'd like to pull this one single directory out of my main repository and into a second, ideally new one.

What is the best process for that? If it makes a difference, the SVN repository is hosted on a (... checks... ) FreeBSD machine.

It's worth noting that while I need to retain the version history in the new repository, there's no need to obliterate the content in the old; it can just sit there, for all I care.

like image 779
Chris R Avatar asked Feb 19 '09 04:02

Chris R


2 Answers

You could use svnadmin dump and svnadmin load to create a new repository from the original one; then copy the directory that doesn't really fit into your scheme to a better location, then delete everything else. In the original repository you would simply delete the non-fitting directory. This keeps all history intact, and you end up with two repositories.

There is probably a way to subsequently clean both repositories from the then useless parts of the history (svndumpfilter), but since hard disc space is quite cheap I wouldn't think this necessary. Anyway, the SVN documentation has all the information about it.

like image 107
mghie Avatar answered Sep 20 '22 04:09

mghie


The recommended way to do this is to use svnadmin dump, then filter the dump file with the svndumpfilter tool (see svnbook).

For example, I had a repo with a top-level directory named 'Model', which I wanted to move to its own repo:

svnadmin dump my_orig_repo | svndumpfilter include --drop-empty-revs --renumber-revs Model >model_only.svndump
svnadmin load my_model_repo < model_only.svndump

That creates the new repo with only the Model subdirectory.

For removing it from the original repository, you can simply do an svn rm. This will remove it from the latest version of the repo, and is the simplest way.

But if the Model directory from my example was very large, maybe I would have wanted to remove it entirely from the original. I could do that by repeating the process to create another filtered svn dump file that excluded it instead. Then I would replace the original with the new one that did not have the excluded directory.

like image 38
Droj Avatar answered Sep 21 '22 04:09

Droj