Moving SVN repositories data with history as subfolders into another repository

12,590

Solution 1

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.

Filtering repository history with svndumpfilter tool

The 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:

  1. Dump your current repositories with svnadmin dump,
  2. Filter out only needed repository path in the dumps with svndumpfilter,
  3. Load the filtered dumps to another repository with 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:

  1. Filtering Repository History
  2. svnadmin dump
  3. svnadmin load
  4. svnrdump dump
  5. svnrdump load
  6. svndumpfilter

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.

  1. 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.

  2. Create dump of the REPO repository:

    svnadmin dump C:\Repositories\REPO > REPO.dump

  3. Filter out unnecessary paths from the REPO.dump file:

    svndumpfilter include /trunk/ABC < REPO.dump > filtered.dump

  4. Create empty /loaded folder in the C:\Repositories\REPO2 repository.

  5. Load dump to that folder:

    svnadmin load --parent-dir /loaded C:\Repositories\REPO2 < filtered.dump

That's it!

Repository replication with svnsync tool

The 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.

Solution 2

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
Share:
12,590

Related videos on Youtube

cmbhjv
Author by

cmbhjv

Updated on June 07, 2022

Comments

  • cmbhjv
    cmbhjv almost 2 years

    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?

    • cmbhjv
      cmbhjv almost 12 years
      For example, I have 4 repos (r1,r2,r3,r4) and I need to copy them all to a new repository (repo-all) preserving the history log of r1,r2,r3,r4
  • bahrep
    bahrep over 11 years
    Apache Subversion FAQ has been recently updated with another filtering approach: subversion.apache.org/faq.html#removal
  • Prakash
    Prakash over 10 years
    At step 4 should we create a directory in operating system or create svn directory using svn mkdir?