Revision 14 as of 2009-03-02 13:10:09

Clear message

An Introduction to Revision Control Systems

What is Revision Control?

A revision control system maintains a central repository of files (often source code) which are intended to be editable by a selected group of persons. It stores past versions and information about who modified what at which time. You can read more about it here.

Available Version Contol Systems

Currently we have installed Subversion on all our platforms. Subversion is the de-facto replacement of the well-known CVS version control system. CVS is also available in our environment, but we plan to completely replace the CVS repositories with Subversion ones in the long term.

Subversion

We are running an Subversion server at svn.ee.ethz.ch (svnserve daemon).

To use Subversion you will need most of the time the svn command which is installed on all of our UNIX platforms. On Windows we suggest using TortoiseSVN, also available in our Windows Environment.

First steps

If you haven't got a project to work on yet, you will need a repository for it. Send us a request with the name of the repository you wish to have, a responsible person for it and a list of users who need to have full access to it, to support@ee.ethz.ch . We will create it for you on the server and send you the passwords.

When you have got a repository you can begin with these steps to start with your project:

1. Create a subdirectory in your home directory, preferably with the same name as the repository, which would correspond to the name of one of your projects.

user@hostname:~>mkdir myproj

2. Make first contact with the svn server, you will be asked to enter your password, which will be saved in a hidden .svn folder so you won't be asked anymore.

user@hostname:~>svn checkout svn://svn.ee.ethz.ch/myproj
Authentication realm:  myproj
Password for 'muster':
Checked out revision 0.
user@hostname:~>ls -lA myproj
total 8
drwxr-xr-x   7 muster  myproj        512 May 27 18:11 .svn/

There is the .svn folder in which Subversion stores settings like the project repository, server and so on.

3. Now you can create a structure inside this project. We recommend one like "trunk", "releases" and "tags". The first is for the main development (working directory), the second is for milestones of your development (fixed releases without known bugs) and in tags you can put in fixed steps in your development toward a new release. This is just a recommendation though.

An example of this (not the best way, but just to show how it would work):

cd myproj
mkdir trunk tags releases
svn add trunk tags releases

4. A more elegant way to achieve the same by creating the structure directly on the Subversion-server:

user@hostname:~>cd myproj
user@hostname:~>svn mkdir trunk tags releases

5. You can start now 'populating' the project directory:

user@hostname:~>svn checkout svn://svn.ee.ethz.ch/myproj
A  myproj/trunk
A  myproj/revisions
A  myproj/tags

Note that here you do not create the subdirectories yourself, Subversion does it for you as defined on the server and the system adds necessary information in the .svn subdirectory too.

6. We will now assume that you have got some Perl-files in your home, which you want to add to your trunk.

user@hostname:~>cp ~/perl/*.pl trunk

To let Subversion know that there are new files which need to be stored centrally, do the following:

user@hostname:~>cd trunk
user@hostname:~>svn add *
A         admin_portal.pl
A         adv_reg_portal.pl
A         assign_to_reviewer.pl
A         assign_to_tc.pl
A         attendees.pl
A         build_sessions.pl
A         change_cont_pass.pl
A         change_rev_pass.pl
A         change_tc_pass.pl
...

The 'A' stands for added (to Subversion).

7. We assume now that you have edited some files and want to commit the changes centrally:

user@hostname:~>svn commit -m "Saving the first version" #-m is the comment for this revision
Adding         trunk
Adding         trunk/admin_portal.pl
Adding         trunk/adv_reg_portal.pl
Adding         trunk/assign_to_reviewer.pl
Adding         trunk/assign_to_tc.pl
Adding         trunk/attendees.pl
Adding         trunk/build_sessions.pl
Adding         trunk/change_cont_pass.pl
Adding         trunk/change_rev_pass.pl
Adding         trunk/change_tc_pass.pl
Transmitting file data ..............................................
Committed revision 1.

8. We could now delete the files in the trunk directory and a checkout or update would again fetch the files from the last revision:

user@hostname:~>rm -r trunk
user@hostname:~>svn checkout svn://svn.ee.ethz.ch/myproj/trunk/
A  trunk/logadmin.pl
A  trunk/submit_paper.pl
A  trunk/enroll.pl
A  trunk/include
A  trunk/include/header_one.inc
...
Checked out revision 4.

10. Before editing files, you should always do a svn update to get the latest revision of the files.

user@hostname:~>vim trunk/admin_portal.pl
user@hostname:~>svn commit -m "saving admin_portal.pl" trunk
Sending        trunk/admin_portal.pl
Transmitting file data ...
Committed revision 5.

Note: Revision 5 is a set for the repository tree (for ALL the files) even if the only difference between revision 4 and 5 is in the file admin_portal.pl.

11. We can now generate a 'tag' (a snapshot of the last revision):

#as a first important step, check-in all changed files of the trunk
user@hostname:~>svn commit -m "pretagging commit" trunk
#then do the tagging directly on the server
user@hostname:~>svn copy -m "tagging version release-1.0" svn://svn.ee.ethz.ch/myproj/trunk \ svn://svn.ee.ethz.ch/myproj/tags/release-1.0;

To remove a badly tagged version you can do this too directly server:

user@hostname:~>svn rm svn://svn.ee.ethz.ch/myproj/tags/badlytaggedversion

To have a look which taged versions are available:

user@hostname:~>svn ls svn://svn.ee.ethz.ch/myproj/tags/

12. To move whole branches from one place in the repository to another:

user@hostname:~>svn mv svn://svn.ee.ethz.ch/myproj/trunk/test/subdir svn://svn.ee.ethz.ch/myproj/trunk/plan/

Further steps

This above were just basic steps to show you the concept behind Subversion. We recommend you to read the reference book called Version control with Subversion

If you want to change your SVN-password, proceed atChanging your Subversion password

Migrating a CVS to a Subversion Repository

After logging in on a Solaris-machine, execute the following command:

usr/pack/subversion-1.2.1-rp/cvs2svn/cvs2svn --create -s $URL_OF_NEW_SVN_REPO $URL_OF_OLD_CVS_REPO

Trac

As a feature we have installed Trac which is available for all Subversion repositories at svn.ee.ethz.ch or for selfmanaged Subversion repositories in your home. What is Trac?

At the core of Trac lies an integrated wiki and issue/bug database. Using wiki markup, all objects managed by Trac can directly link to other issues/bug reports, code changesets, documentation and files. Examples of trac based websites are:

You can activate trac for your repository in a few minutes as described here

CVS

We are running a CVS pserver on cvs.ee.ethz.ch The most important commands

  1. cvs update -dP

    • Use this Command to synchronise your local checkout directory with the data on the server. (The newer version of files is on the server)
  2. cvs commit

    • After changing or creating new pod files use this command to syn- chronise your local checkout directory with the data on the server. (The newer version is in your directory and you want to update the files on the server!)
  3. cvs commit <filename>

    • Use this command, if you want to synchronise only one file.
  4. cvs add <filename> or <directoryname>

    • Use this command before commiting, if you want to add new pod files or new directories to the cvs files.
  5. cvs delete <filename>

At first delete the file manually in your local checkout directory. Then use this command before commiting to delete the file in cvs. How to make the cvs checkout directory in your own directory

  1. mkdir <directoryname>

    • cd <directoryname>

  2. Log in CVS (You must know your username and passwort and the path of files on the server)
    • cvs -d :pserver:<username>@<server>:<path> login

    • Example: cvs -d :pserver: john@cvs.ee.ethz.ch :/usr/cvs/johns_rep login

  3. Checkout
    • cvs -d :pserver:<username>@<server>:<path> checkout .

    • Example: cvs -d :pserver: john@cvs.ee.ethz.ch :/usr/cvs/johns_rep checkout .

See also the CVS FAQ svk git and cogito