I have some repositories, and I need to transform the content of each one in subfolders of another repository preserving their history log... How can I do that?
There are two ways to accomplish the task. Depending on Subversion server distribution and task complexity you may find one of them easier or more convenient than the other.
svndumpfilter
toolThe solution is quite tricky because Subversion repository history filtering works based on paths you specify to include or exclude in a repo dump output. In short you should do the following:
svnadmin dump
,svndumpfilter
,svnadmin load
.You can also use svnrdump tool (exists in SVN 1.7 and later) to perform the dump and load process remotely. See svnrdump dump and svnrdump load.
I strongly advise you to read the following articles from the SVNBook related to the process:
Suppose you have repository C:\Repositories\REPO and folder /trunk/abc in this repository. See the sample steps to move folder /trunk/abc to another repository C:\Repositories\REPO2.
Ensure that all commits that affect /trunk/abc path and its descendants do NOT affect any other path. For example, there is no commit which adds files to /trunk/abc and /another_folder at the same time or copy files from /another_folder to /trunk/abc etc.
Create dump of the REPO repository:
svnadmin dump C:\Repositories\REPO > REPO.dump
Filter out unnecessary paths from the REPO.dump file:
svndumpfilter include /trunk/ABC < REPO.dump > filtered.dump
Create empty /loaded folder in the C:\Repositories\REPO2 repository.
Load dump to that folder:
svnadmin load --parent-dir /loaded C:\Repositories\REPO2 < filtered.dump
That's it!
svnsync
toolThe solution is also tricky however a complex repository filtration may be a bit more convenient with it than the approach described above.
The approach is to replicate the repository with svnsync after configuring path-based authorization rules that deny read access to any paths that need to be filtered out from repository history.
Unlike svndumpfilter
, svnsync
will automatically translate copy operations with an unreadable source path into normal additions, which is useful if history involving copy operations needs to be filtered.
After reading your question I decided to create an utility for you that would solve this problem. The utility is based on SVNKit library and is situated here https://sourceforge.net/projects/svnkitfilter
Just run
$ svnadmin create svn.repo
$ svnkitfilter SRC_URL_1 file:///path/to/svn.svn --prefix prefix/for/repository1
$ svnkitfilter SRC_URL_2 file:///path/to/svn.svn --prefix prefix/for/repository2
...
$ svnkitfilter SRC_URL_N file:///path/to/svn.svn --prefix prefix/for/repositoryN