Setting up Software Development Environment with Trac
Lately we’ve been growing the number of developers we have and it has become difficult to keep up with all the changes and change requests for our new project (and even our older ones). To help with this, we found a wonderful package called Trac which ties well with our Subversion source control software and adds a ticketing system and Wiki to help categorize, prioritize, and document all changes.
There was one major hitch in setting this up: Trac more or less expects that each project has its own Subversion repository, and our configuration had all projects held within the same repository under separate subdirectories. To be fair, Trac does work with this configuration, but there are some bugs not otherwise seen and some features which are hard to use (like the post-commit hook to auto-close tickets, etc.)
Since we want to take full advantage of Trac, and we like to have everything function as advertised, we set about to split our repository. Here is what we had to do…
First, shut down access to the repo and make a dump file of it. In our case, we just turned off apache. This also turned off Trac, which was not a big problem. Dumping the repository is a simple command:
svndump /home/svn/repos > svn.dump
Now, we need to split the projects. This is done with the svndumpfilter
program. We happen to have five projects, so the following steps are repeated for each project. In the examples, the string sysadmin is the name of the project (and top-level subversion directory).
svndumpfilter include /sysadmin > sysadmin.svndump
perl -pi~ -e 's@Node-path: sysadmin/@Node-path: @' sysadmin.svndump
perl -pi~ -e 's@Node-copyfrom-path: sysadmin/@Node-path: @' sysadmin.svndump
This strips out only the /sysadmin
directory from the dump into the new file and fixes the path references to remove the leading /sysadmin
from it. This allows your checked out copies to continue using the same URL to reference this project.
Now, one must create the new repository. In our case, we set up a directory called /home/svn/newrepos
and put things there:
svnadmin create /home/svn/newrepos/sysadmin
svnadmin load sysadmin.svndump
svn delete file:///home/svn/newrepos/sysadmin/sysadmin -m "remove empty dir"
This creates and loads the new repository. The only thing left is to clean out the empty subdirectory created by the split since we moved the files into the “top level” from a subdirectory which the last command does.
Repeat this set of steps for every project in the dump file.
Once this is done, move the old /home/svn/repos
directory out of the way and move the /home/svn/newrepos
directory into its place. Then adjust the apache configuration to change the subversion path from this
SVNPath /home/svn/repos
to this:
SVNParentPath /home/svn/repos
and restart Apache. Run the trac-admin resync
command for each project as well.
Now, the only problem left is that all checked out copies of projects fail to commit updates. Diffs, logs, etc., continue to work, strangely enough. This is easily fixed by a tricking the working copy into thinking it was relocated:
svn sw --relocate http://svnhost/svndir http://svnhost/svndir
which looks like a no-op command, but it performs some kind of magic that allows commits to suddenly work again.