Multiple repositories and subversion
Multiple repositories and subversion
Last time we looked at Multiple projects and subversion 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.
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
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 and subversion article, project2 would have been committed as revision 2.
Delete the original project folders as we don't need them any more:
rm -rf project*
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.
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:
Set up your permissions as outlined in the introduction to svnserve.
Then simply follow the same procedure for repo2.
Checking out the different projects uses the same procedure as before. So from your local workstation, issue the command(s):
svn co svn://220.127.116.110/repo1/project1 ... svn co svn://18.104.22.1680/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.
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.
Don't forget you can secure the connection using SSH as outlined in the previous article.
© 2015 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
See license specifics and DISCLAIMER