TechTip: Integrating CVS and Eclipse

Development Tools
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times
So does Eclipse itself provide this support? Not directly, but it does provide excellent integration with the Concurrent Versions Systems (CVS) product. This article assumes a general understanding of some of the CVS concepts and terminology; if you are unfamiliar with CVS, please visit the official CVS Web site for additional information about how you can start using CVS to facilitate your project's needs.

Getting Started

Let's make a couple of assumptions before we get started:

  • You have an existing CVS project that you want to work with via Eclipse.
  • You have started Eclipse in a fresh workspace.

Now that we've established common ground, you can load your CVS project into your Eclipse workspace by following these simple steps:

  1. Select File > New > Project.
  2. Expand the CVS tab, select Projects from CVS, and click Next.
  3. Fill out the CVS repository's information as shown below in Figure 1 and click Next. (Note that you may need to talk to your CVS administrator to appropriately fill out this form. The Host field specifies the TCP/IP host name of the system hosting the CVS server. The Repository path field specifies the full-qualified path to the CVS repository on the host system (e.g., on a Linux-based system, this might be something to the effect of /home/CVSRep). The Authentication options are of course the user name and password with which connections should be made to the host system. The Connection options instruct Eclipse as to how it should attempt to connect to the host system.)
    Figure 1: Fill out the CVS repository location information. (Click images to enlarge.)
  4. Specify the CVS module to import. You can either manually specify the module to check out or load the list of existing modules and then click Next, as shown below in Figure 2.
    Figure 2: Specify which CVS module to check out.

  5. On the Check Out As screen, select the Check out as project in the workspace option, using the default project name (unless there's some reason you want to customize these options), and click Next.
  6. Click Next on the Check Out As screen.
  7. Select the CVS project branch to check out and click Finish; in most cases, you will want to check out the HEAD branch as this is where most new development occurs.

Congratulations! You have now created your first Eclipse project as it exists in your CVS module!

What Else Can I Do?

Now that you have checked out a CVS module into an Eclipse project, there's a new Team right-click option (Figure 3) available to you on any of your project components (e.g., the project itself, modules, files, etc.).

Figure 3: You've unlocked the Team menu.

You may now access any function CVS normally provides: add file(s) to version control, commit new changes, update per the latest version in the repository, create patches, etc. And as I mentioned earlier, not only can you perform these operations at the individual file level, but you can also do them at the directory level (e.g., you can recursively update or commit all children of a specific directory).

Another nice feature is that any file that has been changed since it was checked out will be marked with a greater-than symbol (>) before its name, making it intuitive that something's changed.

Another helpful feature Eclipse provides is the Synchronize with Repository function under the Team menu. This function provides the ability to view a listing of all files that you have changed or that have changed in the CVS repository. You are then given the opportunity to commit new changes, accept incoming changes, or if necessary, merge changes. This provides a simple mechanism to determine which new code you pull from the repository and which code you push to the repository that traditional CVS clients do not offer.

In a nutshell, these integration features allow you to conveniently bundle your versioning system and your development into a single environment (i.e., Eclipse) in an extremely user-friendly fashion. While there are several more features to explore, these steps should point you in the right direction. Until next time, happy coding!