Posts

Extract multiple partial directories from a Subversion repository

Multiple parts or subdirectories of an existing Subversion repository should be synced to an exposed Subversion server to give someone access to the code in this directories – only those directories and only readonly. So bear in mind that this solution is only working one way (and downhill with tailwind).

First attempt:

Since Subversion 1.5 partial sync of a repository is possible. This sounds promising but after some searching in the documentations I throw away this plan because only one subdirectory can be synced to a mirror repository at a time. As I had multiple to sync, this solution would never gonna work. More information this can be found here (“Q: Can I mirror a subdirectory of a master repository?”). I spare you the details on creating a synced repository here because there is plenty of guides and documentations out there.

Second attempt:

My second attempt was just dumping the source repository and use svndumpfilter to only include the directories which should be exposed later on. The size and number of commits aren’t the issue here but in repositories files and directories tend to get moved, renamed, deleted and so on. For the dump, you have to include all those special sources which changed over time to the include list of svndumpfilter and this gets really frustrating after you started the 10th time. Also the standard svndumpfilter doesn’t work very well in some cases. Therefor some people implemented svndumpfilter in Python which should help solving those problems. You can find it here. But still after trying out various options of svndumpfilter3 I wasn’t able to cleanly export the parts I needed. So I started scripting and came up with clearly not the best solution, but a solution.

As every missing directory or file needed a new command line option it is fairly boring to run the script, open it, add the option, save and rerun it.

Here comes my first script (dump-testrepo.sh) into work. It runs the svnadmin dump and the svndumpfilter3 combination, reads the output and automatically adds the missing parts to itself.