Is there a simple way to copy a directory from one repository into another repository with copying all of the history?
Use the svnsync — Subversion Repository Mirroring command:
svnsync
is the Subversion remote repository mirroring tool. Put simply, it allows you to replay the revisions of one repository into another one.
The Subversion documentation for the svnsync
command has the following warning (as of version 1.7) implying that once some other SVN commands are used to modify a mirror repository, svnsync
should not be used with that particular mirror again:
svnsync
is very sensitive to changes made in the mirror repository that weren't made as part of a mirroring operation. To prevent this from happening, it's best if thesvnsync
process is the only process permitted to modify the mirror repository.
You can create a dump file using svnadmin dump
, then import to a new repository with svnadmin load
.
As suggested in the Subversion book:
svnadmin dump path/to/repos_src \
| svndumpfilter include path/inside/svn/to/directory \
| svnadmin load path/to/repos_dst
With an example:
svnadmin dump /var/lib/svn/old_repo \
| svndumpfilter include trunk/my_project/common_dir \
| svnadmin load /var/lib/svn/new_repo