Multiple repositories and subversion
Last time we looked at multiple projects which was a nice way of serving more than one project from the same repository.
But what if we wanted our projects to be completely separated? Well, serving multiple repositories is the answer.
There seems to be a bit of a rumour that this is a difficult route to go. Nothing could be further from the truth. Multiple repositories are incredibly easy to set up and to serve and do solve issues related to version numbering and so on.
clean up
Let's start with a clean slate: If you have been following the previous articles, you may well have project1 and project2 in the 'work' and 'repository' folders on your Slice.
Let's delete the old stuff:
cd ~
rm -rf /home/demo/repository
rm -rf /home/demo/work/*
Now we have a clean sheet to work from.
create the repositories
Start by creating a folder to hold our repositories and then, using svnadmin, create two new repositories:
mkdir repositories
...
svnadmin create repositories/repo1
svnadmin create repositories/repo2
create projects
Next, I'm going to create two incredibly simple projects and import them into the separate subversion repositories:
mkdir project1
touch project1/project1.txt
...
svn import /home/demo/project1 file:///home/demo/repositories/repo1/project1/trunk -m "import project1"
mkdir project2
touch project2/project2.txt
...
svn import /home/demo/project2 file:///home/demo/repositories/repo2/project2/trunk -m "import project2"
Notice that this time, for each initial import subversion reported:
Committed revision 1
Now the two projects are separated. Had we used the technique described in the multiple projects article, project2 would have been committed as revision 2.
delete originals
Delete the original project folders as we don't need them any more:
rm -rf project*
svnserve
We could simply check out the projects on the same machine but that's not much fun. Let's setup svnserve to serve both repositories at the same time.
This is exactly the same as when serving one repository:
svnserve -d -r /home/demo/repositories/
That's it. It is incredibly simple to set up. Naturally, if you have a firewall, ensure you allow connections to port 3690. If you are not sure how to go about that, details can be found in the introduction to svnserve article.
permissions
As we have created two different repositories (repo1 and repo2) we can now set different permissions for each one.
So to configure permissions for repo1, edit the following file:
nano /home/demo/repositories/repo1/conf/svnserve.conf
Set up your permissions as outlined in the introduction to svnserve.
Then simply follow the same procedure for repo2.
checkout
Checking out the different projects uses the same procedure as before. So from your local workstation, issue the command(s):
svn co svn://123.45.67.890/repo1/project1
...
svn co svn://123.45.67.890/repo2/project2
Add, edit and delete files as you would for any other project under subversion control. Any commits you make will be for that project only.
permissions demo
To demonstrate different permissions with one instance of svnserve running, I set the permissions in repo1/conf/svnserve.conf to this:
anon-access = read
auth-access = write
and for repo2 I set them to this:
anon-access = none
auth-access = none
As you may imagine, when I tried to check out project1 (from repo1) I had no issues, but when I tried to check out project2 (from repo2) I was denied access:
That's exactly what I wanted. Nice.
SSH
Don't forget you can secure the connection using SSH as outlined in the previous article
PickledOnion.


Article Comments:
Frank Sun commented Fri Sep 14 05:27:04 UTC 2007 ago:
It seems it doesn't work on Windows Server 2003 with svn 1.4.5 when the root directory is on top of the two repositoy directories. It only works when I assign the root diretory to the specific repository directory.
PickledOnion commented Fri Sep 14 08:20:54 UTC 2007 ago:
Hi Frank,
Could you confirm which bit does not work?
The creation of the two repositories on the Slice?
Or when you check out the repositories from your Slice to Windows Server 2003 (i.e. Windows Server is acting as your 'local workstation' in this article)?
Many thanks, PickledOnion.
George Philip commented Thu Dec 27 23:13:47 UTC 2007 ago:
It is working like a charm for me on windows Server 2003. If you have SVNService running you might have to remove it and add it again with the right parameters so as to point to the root repo. George Philip. elavatta.
Sean commented Wed Jan 23 21:32:31 UTC 2008 ago:
Works for me on a Windows server. Note that if you're using a graphical repository browser, like Tortoise, you can't navigate to the "top-level" folder. It'll say there's no repository there. But you can navigate directly to one of your created repositories.
Markus Mahlberg commented Mon Jul 28 05:19:30 UTC 2008 ago:
Thanks for this article. The svn book is not as clear about this setup as you are.
Pretty straight forward