Version Control on Mac OS X, Part 2

The first
article of this series introduced you to the basics of version control,
discussed some examples of using it on projects, and outlined what version
control systems are available under Mac OS X. In this article, you'll
get a chance to apply this knowledge by using one of the most popular
version control systems, Concurrent Versions System (CVS), on a sample
project under Project Builder. Specifically, you will learn how to set up
CVS for remote access, import a project into CVS, and use CVS commands
from within Project Builder. Before continuing, make sure you have read
the first article of this series and "In
Sync with CVS," by James Duncan Davidson. In addition, make sure you
install the Apple developer tools, freely available from Appleís developer
site.

The Apple developer tools come with an IDE called Project Builder, which
includes a development environment to edit, build, debug, and run Mac
OS X applications. Project Builder does not include the main development
tools (compiler, linker, version control, etc.) as part of the program.
Instead, it uses UNIX development tools such as gcc, g++, gdb, and CVS.
In a sense, Project Builder is evolutionary; it continues the line of
IDE-based development environments for the Macintosh, but breaks with
tradition by using external UNIX-based tools for implementing its development
tasks. This strikes a nice balance by providing a modern interface for
application development while leveraging the strengths of the UNIX tool
set.

Project Builder supports access to CVS through its GUI. As you learned
in the first article, CVS is by no means the only version control system
for Mac OS X. However, it is one of the most popular systems from the
UNIX world to find its way to Mac OS X, and is supported by Project Builder.
For these reasons, as well as its popularity in the open source community,
it makes a good choice for version control under Mac OS X.

Setting Up CVS

There are two ways to set up CVS -- for local access and for remote access.
Local access means that the CVS repository is located on your development
machine. With remote access, the repository resides on a machine on
the network and you develop on any machine you wish, connecting to
the repository over the network.

Though both methods have their advantages and disadvantages, I prefer
remote access. These days, networks are ubiquitous, so I can keep my
repository in one place and access it from many locations. Another good
reason for choosing remote access is for use on projects with a geographically
distributed development team. For example, envision the following: you
and some friends want to develop a new editor for Mac OS X. Each person
lives in a different part of the country. A requirement of the project
is that members need to access and update each otherís work at any time.
Since CVS is designed to work over the network, one developer sets up
a CVS repository on a single, networked machine. The other developers
configure their environment to remotely access the repository over the
network. Now all developers have access to CVS as though the repository
were accessible within their file system.

The following steps show you how to set up CVS for remote access. To
do this, you will need two machines connected to the network; one that
holds the CVS repository and one for development. Letís call the machine
that holds the repository the "CVS remote host" and the development
machine the "CVS client host."

The first step is to set up the CVS remote host. For this example, I
will assume the host name of the CVS remote host is "cvshost.somedomain.edu,"
the username is "omalley," and the CVS repository is located in /Users/omalley/cvs-repository.

If necessary, create an account for yourself and others that will
access to the repository.

Open System Preferences (located in /Applications), click on the
Sharing icon, and click on the Remote Login checkbox. This runs
the SSH daemon, enabling you to connect to the machine over SSH.

Open the Terminal application (located in /Applications/Utilities)
and create a directory called cvs-repository, which will hold the CVS
repository for your projects. Place this directory on a disk partition
that is large enough to handle the anticipated file storage requirements.
Try to be overly conservative when estimating your disk requirement.
For this example, place the repository in your home directory.% mkdir ~/cvs-repository

Run the CVS initialization command to set up the repository. You
only need to run this command once, before anyone uses the new repository.% cvs Ėd /Users/omalley/cvs-repository init

Update the cvswrapper file, located in /Users/omalley/cvs-repository/CVSROOT,
to properly handle binary files and bundles. To do this, see "In
Sync with CVS" and Appleís Project Builder documentation.

Now that the repository is ready, you can set up the CVS client host.
To do this, perform the following steps on the CVS client host.

Generate your SSH keypair files, using the same password as your
user account on the CVS remote host.

% ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/omalley/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/omalley/.ssh/id_rsa.
Your public key has been saved in /Users/omalley/.ssh/id_rsa.pub.
The key fingerprint is:
1a:61:41:ad:a2:f2:e3:4b:d9:bd:49:af:c5:5e:46:66 omalley@G4.local.

Add your public key to the CVS remote hostís authorized_keys2 file.
The following example assumes you do not have a ~/.ssh directory
or an authorized_keys2 file on the CVS remote host.