Monday, May 10, 2010

Revision control with subversion

Subversion is a revision control system that stores your code on a central server in a repository.

Install

Let install subversion (if you followed previous post on how to mount ext3 partitions securily, you will need remount /usr and /var so they can be used by apt):
apt-get -y install subversion

Create repository

Once Subversion is installed, the next step is create your repository. We are going to keep all our repositories below /var/lib/svn/repos directory.
deby:~# mkdir -p /var/lib/svn/repos
The only users of security group svnusers can access repositories.
groupadd -r svnusers
chgrp svnusers /var/lib/svn/repos
chmod o-rwx /var/lib/svn/repos
ls -l /var/svn
Add users to group svnusers:
usermod -a -G svnusers user1
There are two common conventions for organizing projects. One is project major, and the other is project minor. In project major, each project has its own repository; in project minor - the repository is top-level. Here is a command to create svn repository for project1 using project major convention.
svnadmin create /var/lib/svn/repos/project1
Let secure project repository (consider use per project group assignment).
chgrp -R svnusers /var/lib/svn/repos/project1
find /var/lib/svn/repos/project1 -type d | xargs chmod g+x
chmod -R g+w,o-rwx /var/lib/svn/repos/project1
Now login as user1 and checkout:
user1@deby:~$ svn co file:///var/lib/svn/repos/project1/
Checked out revision 0.

Repository top directories

It is recommended create the following top level directories: trunk, branches, tags.
user1@deby:~$ cd project1/
user1@deby:~/project1$ svn mkdir trunk branches tags
A         trunk
A         branches
A         tags
user1@deby:~/project1$ svn commit -m 'added top directories'
Adding         branches
Adding         tags
Adding         trunk

Committed revision 1.

No comments :

Post a Comment