Centralized Version Control (CVS, Subversion)

Steven J Zeil

Last modified: Feb 22, 2021
Contents:

Abstract

Centralized version control stores the history of the code base on a separate server from which copied can be provided to all developers.

In this lesson we will look at the advantages of centralized version control over local control. Particular attention will be paid to the area of collaboration where local locking mechanisms are replaced by after-fact detection and resolution of conflicting changes.

We will look at one of the most influential version control systems, CVS.

Centralized Version Control

rcs kept its repository of history information in the “live” working directories.

Centralized version control systems keep a project repository in a location separate from the programmer’s work area.

1 CVS

1.1 History


Where’s the Repository?

The earlier commands presume that we have, somehow, already established a connection with the repository.


Local CVS Repositories

If the repository is on a local file file system,

cvs -d /usr/local/cvsroot checkout myProject/projectRootDir

or record this info in an environment variable:

setenv CVSROOT /usr/local/cvsroot
cvs checkout myProject/projectRootDir


Remote Repositories

The same techniques (-d, CVSROOT) can be used to specify remote repositories.


pserver Example

sirius:~/temp/tmp> setenv CVSROOT :extssh:zeil@cvs.cs.odu.edu:/home/cvs/dlib
sirius:~/temp/tmp> cvs checkout AlgAE
cvs checkout: Updating AlgAE
U AlgAE/.project
U AlgAE/AlgAE_layout.odg
U AlgAE/LICENSE.txt
U AlgAE/README.txt
U AlgAE/build.xml
U AlgAE/buttons.gif
U AlgAE/buttons.odg
U AlgAE/jhbasic.jar
U AlgAE/junit-4.10.jar
cvs checkout: Updating AlgAE/AlgAE_screenshot.png
   ⋮
sirius:~/temp/tmp> ls -ld AlgAE
drwxrwxr-x 11 zeil faculty 1024 Feb 21 13:39 AlgAE/

The History Commands

1.1.1 Eclipse Integration

Eclipse includes CVS support in its normal distributions.


Checking Out an Existing Project

Pulling an existing project from CVS into Eclipse is pretty straightforward:


Eclipse Integration: Creating a Project

To add a new project to an existing repository:


Working with History in Eclipse

Right-click on a file or directory and look in the “team” menu

You might want to put .cvsignore under version control.


Examining History in Eclipse

Right-click on a file or directory and look for

1.2 Exploration

Branches

 


Creating Branches

Leave “Start working in the branch” checked. Click OK.


Merging a Branch Back Into the Main Trunk

  1. Make sure that your copy of the branch is up-to-date, all changes checked in.
    • If you want to allow for continued use of the branch after the merge, add a tag on the branch.

Right-click on a project with an up-to-date copy of the branch, and select “Team Tag as Version … ”

1: To begin the actual merge, start with an up-to-date copy of the main trunk (HEAD).

2: Right-click on the HEAD project and select “Team Merge … ”.

3: CVS will compare the checked-in copy of the branch against the files in your local HEAD project.

4: Having resolved all changes, you now have a local copy of the project, associated with the HEAD branch in CVS, with a merged copy of code from the former HEAD and from the other branch.

1.3 Collaboration

Resolving Conflicts

During synchronization, changes are categorized as

These presumably need to be updated.

These presumably need to be committed.

These presumably need to be merged


Conflict Editors

Many IDEs provide special side-by-side editors for reviewing and resolving conflicts.

 

This, for example, is the Eclipse editor

2 Subversion

Subversion

Subversion (a.k.a. svn) is a later version control system based on the same centralized model as CVS.

2.1 History

Differences between CVS and Subversion w.r.t. history:

2.2 Exploration

2.2.1 Subversion Doesn’t Understand Branches …

Subversion does not implement a distinct mechanism for branching.


… but it Does Branches Anyway

 
A typical subversion repository looks like this.


Is This an Improvement?

I can’t decide if Subversion’s approach to branches is inspired or lazy.

The two are not, of course, mutually exclusive.

2.2.2 Subversion Doesn’t Understand Tags …

 
… but it does tags anyway, the same way it does branches.

2.3 Collaboration

No real differences between CVS and SVN

2.4 Eclipse Integration

has to be installed as a plug-in

Relies on some non-Eclipse libraries that must be installed separately.