Chapter 4. Version Control Systems

Source code management, or version control, is the practice of managing the revisions of a code with comments so that the code can be retrieved easily. The concept of version control systems (VCS) has been around for a long time. The first implementations were file-oriented, centralized, and without network access capability.

An evolution has come with Concurrent Versioning System (CVS) that was explicitly designed for collaborative development and had a merging mechanism instead of a locking-based one. The latest generation presents a major concept modification, that is, a complete decentralization.

This clearly seems more appropriate, for nowadays network-based systems are likely going to be the most used ones in the near future. A good versioning system should at least offer the following features:

  • The possibility to add, remove, rename, or delete files
  • The possibility to find which files have been altered by which user and when
  • The provision to keep track of several versions of a product
  • The possibility to go back and forth among versions
  • The possibility to merge code
  • The provision to revert a modification (go back in history)

In this chapter, we are going to present the main characteristics of VCS and how to make use of the three most popular version control systems inside the Eclipse platform, that is, CVS, Subversion (SVN), and Git.

CVS

The development of a product is usually performed by several software engineers. Version control systems such as CVS are typically used to manage the files related to the development. Although version control systems are generally applied on programming projects, they are not limited to that purpose and can be used for any task that involves the management of datafiles.

CVS is based on the concept of branches, where each developer can commit his modifications to the same set of resources. The main branch, HEAD, is generally used when there is a certainty that the implementation is stable. It is possible to use several branches and merge the files to the main branch at any moment.

CVS repositories maintain a history of every committed change made to the resources over time. A resource may be compared with or replaced with any prior existing revision.

Eclipse provides facilities for merging, committing, and accessing a project's history. In the following sections, we'll present some of the basic functionalities regarding the use of the CVS technology.

Repository

The first thing that needs to be done is to connect the Eclipse workspace to a CVS repository. This operation can be performed by navigating to File | New | CVS | CVS Repository Location. A window like the following screenshot will appear:

Repository

It is necessary to select the Host, Repository path, Username, and Password of the desired repository. The repository will be added to the workspace, and the following screenshot of the CVS Repositories view will be seen:

Repository

Checking out a project

In order to check out a project, expand the HEAD label, select the underlying project, right-click on it, and go to Checkout. This will load the project into the workspace.

It is also possible to use the wizard by navigating to File | New | CVS | Projects from CVS. You can select the repository location and from the second page, you can choose the list of projects with which you wish to work.

Synchronizing

While you are editing the resources of a project, there will be times when you will want to commit it back to the repository. For this purpose, you can click on the resource and select Synchronize with Repository.

A synchronize view will be opened. There will be three options in it:

  • The Incoming mode, where the view shows only incoming changes
  • The Outgoing mode, where the outgoing changes are shown
  • Both modes together

To commit a change to the repository, you can navigate to the outgoing changes option and select Commit. To load any possible changes to your workspace, right-click on the incoming changes option and select the Update option.

It is possible that conflicts may occur when committing or updating; for example, let's assume you and another developer have modified the same resource. In that case, a merge tool can be used to select the version you want to keep.

Branches

When there is need to keep multiple versions of a product, for instance, it is recommended that a branch be created; this can be done by performing the following steps:

  1. After right-clicking on the project, go to the Branch option.
  2. In the window that follows, leave the start working in the branch box checked.

    CVS will automatically propose a version name that can later be used for merging purposes.

  3. In the CVS repository view, it is possible to see the created branch under the Branches node.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset