Multiple projects and subversion
So you've got your subversion repository created and you have svnserve running nice and securely using the SSH protocol (see the subversion articles for more details).
So what happens when you want to run version control on another project?
Well, there are two routes you could take here.
Firstly, you can add another project to an existing subversion repository. This technique is discussed in this article.
Secondly, you can create another repository and include the new project in that.
Like everything, there are advantages and disadvantages to both techniques. The first option, while perhaps the easiest to configure, does mean that all projects within that repository have the same permissions. A good example of multiple projects in one repository can be found at the superb techno-weenie.net repository.
There are some 17 projects in the one repository. Quick, convenient and very useful.
However, if you wanted one of the projects to be hidden from users, thus having different permissions, you may want to set up multiple repositories. This will be discussed in the next article.
So how do we go about adding another project to an existing repository?
I will use the paths described in the previous subversion articles where the subversion repository is located at:
/home/paul/repository
I have one project, rather originally called 'project1', imported like so:
svn import /home/paul/project1/ file:///home/paul/repository/project1/trunk
Adding further projects is literally a repeat of steps used with project1.
To keep with the naming convention, we'll call this project, er, project2 (sorry).
So to create project2:
mkdir project2
touch project2/layout.txt
To add it to the existing repository (on one line):
svn import /home/paul/project2/ file:///home/paul/repository/project2/trunk
--message "Initial import of project2"
The output of my import showed this:
Adding /home/paul/project2/layout.txt
...
Committed revision 9.
Why would this be revision 9 when it is the first import of project 2? The answer is that the whole repository is versioned. It is version 9 of the repository, not of the individual projects.
Having said that, each file in the repository is individually versioned so it knows what file has been updated or added and what version it relates to. So, without over complicating the issue, individual files are versioned, but the import created revision 9 of the repository.
Now delete the original project2 folder:
rm -rf project2
Move into your 'work' directory and 'check out' both projects:
cd work
svn co file:///home/paul/repository/project1/trunk project1
svn co file:///home/paul/repository/project2/trunk project2
Just to make sure you have both projects have a little look:
ls project1/
goodbye.txt hello.txt blue.txt new.txt test.txt zz.txt
...
ls project2/
layout.txt
As you can see, I've been playing with project1 and have a few (daft) files in there. But project2 is exactly as I have just created.
You can also do this remotely like so :
svn co svn+ssh://123.45.67.890/home/paul/repository/project1/trunk project1
...
svn co svn+ssh://123.45.67.890/home/paul/repository/project2/trunk project2
That's it. Have as many projects in your repository as you want. The next article will look at creating and serving multiple repositories so each project is versioned separately and with different permissions.
PickledOnion.
Digg it |
del.icio.us |
reddit |
StumbleUpon

Subscribe to Feed