Most subversion tools create a default repository layout with /trunk, /branches and /tags. The documentation also recommends not using separate repositories for each project, so that code can be more easily shared.
Following that advice has led to me having a repository with the following layout:
/trunk /Project1 /Project2 /branches /Project1 /Project2 /tags /Project1 /Project2
and so on, you get the idea. Over time, I've found this structure a bit clumsy and it occurred to me that there's an alternative interpretation of the recommendations, such as:
/Project1 /trunk /branches /tags /Project2 /trunk /branches /tags
So, which layout do people use, and why? Or - is there another way to do things that I've completely missed?
I find that the Subversion Repository Layout blog post summarizes this pretty well:
So, to paraphrase:
The whole post is worth the read.
I greatly prefer the second, using maven or ant/ivy to ingest the artifacts from other projects if needed.
I also prefer to have a single project per repository, or a small number of related repositories.
It simplifies access control, which is easier at the repository level than the path level within the repository - particularly when authenticating against LDAP.
Backup/restore operations are a little more complicated initially as you have to loop through all the repositories to do a hot copy, but in the unlucky event you have to restore only one repo - the others needn't be taken offline or loose any data. As projects die, the repositories can simply be deleted thus saving you space on future backups.
Hook scripts become simpler when there is only one project (or a small number of related projects) per repository, you don't have to examine the affected path to conditionally take action in your hook.
As retracile noted, one monolithic repository is likely going to be a huge pain if you ever want to selectively export using svndumpfilter - the number of changed paths causing it to die is likely to be high.
Upgrading the repository schema for future versions of svn requires more effort - you have to do it n times rather than once... but it can be scripted and you needn't coordinate everyone at once.
If someone commits a password, and you have to obliterate it, you can do the dump/filter/reload quickly in one repo while not affecting other teams.
One piece of advice if you go this route - have a different .conf file per repo rather than one huge one, again it's easier to manage as well as providing comfort that some timestamps are going to be old - if something's amiss you can look for recent changes easier.
I prefer the second. With the second, if people's permissions are different between the two projects, it's easier to implement.
The second layout is the way to go. One good reason is to allow or deny a developer to work with one of the projects.
Refer Repository Layout from the svnbook
I decided to bite the bullet and restructure my repository. I wrote a small program to assist (below). The steps I followed were:
svn checkout
the entire repository. This took a long time and a lot of disk space.svn delete
the obsolete trunk, tags and branches folders)svn commit
back to the repository.This whole process took time, but I decided to take this approach because modifying a working copy is a lot safer than hacking up a live repository and I had the options to simply throw away the working copy if it all went wrong, to fix any issue in the working copy and commit the entire restructure as a single revision.
Here's the C# code I used to do the moving. Requires SharpSvn library.