How to split an SVN folder into its own repository

2019-01-29 23:38发布

I want to split a directory from a large Subversion repository to a repository of its own, and keep the history of the files in that directory.

I tried the regular way of doing it first

svnadmin dump /path/to/repo > largerepo.dump
cat largerepo.dump | svndumpfilter include my/directory >mydir.dump

but that does not work, since the directory has been moved and copied over the years and files have been moved into and out of it to other parts of the repository. The result is a lot of these:

svndumpfilter: Invalid copy source path '/some/old/path'

Next thing I tried is to include those /some/old/path as they appear and after a long, long list of files and directories included, the svndumpfilter completes, BUT importing the resulting dump isn't producing the same files as the current directory has.

So, how do I properly split the directory from that repository while keeping the history?

EDIT: I specifically want trunk/myproj to be the trunk in a new repository PLUS have the new repository include none of the other old stuff, ie. there should not be possibility for anyone to update to old revision before the split and get/see the files.

The svndumpfilter solution I tried would achieve exactly that, sadly its not doable since the path/files have been moved around. The solution by ng isn't accetable since its basically a clone+removal of extras which keeps ALL the history, not just relevant myproj history.

18条回答
可以哭但决不认输i
2楼-- · 2019-01-29 23:46

We developed Subdivision, a GUI tool designed to split svn repositories.

Subdivision analyzes the repository and calculates the history of the files as they are being copied and moved throughout the repository. Using this information, your selections are intelligently augmented to avoid all "Invalid copy source path" errors.

In addition to splitting a repository, Subdivision can be used to delete files from a repository as well as extract files and folders into a new repository.

Subdivision is free for small repositories.

查看更多
祖国的老花朵
3楼-- · 2019-01-29 23:47

Why not replicate the entire repository, dump it in to a new one. Then branch out the trunk, delete the head and merge the portions you want back in to the trunk from the branch. Then you have kept the history and split out the parts you want to a new repository.

  1. Dump to /trunk
  2. Branch /trunk to /branches/trunk
  3. Delete /trunk
  4. Merge /branches/trunk/whatever back in to /trunk or /trunk/whatever

This way you have kept all the history, and selectively picked the parts you want.

查看更多
啃猪蹄的小仙女
4楼-- · 2019-01-29 23:47

I'm also looking for an answer on this question (having to deal with it myself). Based on Alex' answer, I found http://furius.ca/pubcode/pub/conf/common/bin/svndumpfilter3.html which claims to fix some of the svndumpfilter2 issues. I believe it is a partial solution.

The good:

A rewrite of Subversion's svndumpfilter in pure Python, that allows you to untangle move/copy operations between excluded and included sets of files/dirs, by converting them into additions. If you use this option, it fetches the original files from a given repository.

Concern:

Important

Some people have been reporting a bug with this script, that it will create an empty file on a large repository. It worked great for the split that I had to do on my repository, but I have no time to fix the problem that occurs for some other people's repositories

查看更多
男人必须洒脱
5楼-- · 2019-01-29 23:47

If you don't need the entire history you can pick it up from just after the error. If your error was at revision 412 then you can try picking it up right after with:

svnadmin dump /path/to/repo -r 413:HEAD > largerepo.dump

I realize this may not be a perfect solution either but it may be good enough in your case.

You may want to also just do this all in one step

svnadmin dump /path/to/repo -r 413:HEAD | svndumpfilter include my/directory > mydir.dump
查看更多
趁早两清
6楼-- · 2019-01-29 23:50

Stumbled onto this problem and found this tool svndumpsanitizer It seemed to work well I was able to import the file it created into a new repository.

查看更多
做自己的国王
7楼-- · 2019-01-29 23:50

Based on the answer by ng., but with filtering and dropping empty revisions.

Step 1. Dump and filter:

svnadmin dump /path/to/repository > fulldumpfile
svndumpfilter include trunk/the/part/you/want --drop-empty-revs --renumber-revs < fulldumpfile > dumpfile

Step 2. Create new repo. (note that this can also be done e.g. with Tortoise SVN)

svnadmin create /path/to/new_repo

Remember to add whatever you need to be able to checkout (permissions and such).

Step 3. Checkout and add base folder (can also be done e.g. with Tortoise SVN)

svn checkout http://localhost/new_repo /some/checkout/path/newrepo
cd /some/checkout/path/newrepo
# to be able to create "trunk/the/part/you/want" you will need to add parent dir:
mkdir -p trunk/the/part/you
svn add trunk
svn commit -m "old base"

Step 4. Load filtered dump

svnadmin load /path/to/new_repo < dumpfile

Step 5. Move old root to new root (can also be done e.g. with Tortoise SVN)

cd /some/checkout/path/newrepo
svn update
svn move trunk/the/part/you/want/* trunk/
svn move tags/the/part/you/want/* tags/
svn move branches/the/part/you/want/* branches/
svn commit -m "re-structure base"

You should now have the part you want from the old repository as the trunk of the new one.

查看更多
登录 后发表回答