Sample Program: MyPing
Now that CVS is set up, we can begin looking at CVS and Project Builder.
The example program you will use in this article is MyPing -- a Cocoa
front end for the UNIX
ping tool. You use
ping to test if a host is
available on the network and measure how long packets take to reach
it. For example, imagine you are trying to access a web site, but for
some reason, it is taking a long time to reach the site. Using
you can verify that the site is alive (online) and measure the delay.
(To determine the origin of the delay, use
# Determine if a host is alive. % ping www.gnu.org PING www.gnu.org (188.8.131.52): 56 data bytes 64 bytes from 184.108.40.206: icmp_seq=0 ttl=47 time=89.463 ms 64 bytes from 220.127.116.11: icmp_seq=1 ttl=47 time=45.884 ms # Determine if host is alive, waiting 2 seconds between pings, # sending 4 pings. % ping -i2 -c4 www.gnu.org PING www.gnu.org (18.104.22.168): 56 data bytes 64 bytes from 22.214.171.124: icmp_seq=0 ttl=47 time=67.659 ms 64 bytes from 126.96.36.199: icmp_seq=1 ttl=47 time=45.732 ms 64 bytes from 188.8.131.52: icmp_seq=2 ttl=47 time=45.299 ms 64 bytes from 184.108.40.206: icmp_seq=3 ttl=47 time=47.636 ms --- www.gnu.org ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max = 45.299/51.581/67.659 ms
MyPing adds a Cocoa interface to
ping, making the program accessible
to users who are not comfortable with the UNIX command line. In addition,
it is a nice example of how you can leverage the power of command-line
tools to create new programs -- something UNIX people do all the time using
scripting languages like Perl and Python.
This version of MyPing implements the basics. In the next article, we
will add some new features, including logging
ping output to a file.
Before continuing, download MyPing.
Importing MyPing into CVS
Now that your environment is set up and you have downloaded the MyPing project, it is time to get started using CVS under Project Builder. Unfortunately, Project Builder only supports a subset of CVS functionally from its interface. To access all CVS commands, you can use the command line or the GUI-based Concurrent Versions Librarian (CVL) (more on this in the final article). For this article, we will use the command line.
One CVS function not accessible from Project Builder is the
As you know, before CVS can track changes to your project, you need
to import the project into CVS, which places it under version control.
To accomplish this, you use the CVS
import command. The
takes the files in the current working directory (and its subdirectories)
and adds them to the CVS repository.
cvs import [-options] repository vendortag releasetag
The options argument specifies options applied by the
repository argument indicates the directory where CVS will store
the project within the repository. For example, if you specify MyPing
as the repository name, the MyPing directory is stored at
/Users/omalley/cvs-repository/MyPing, on the CVS remote host. See
the CVS man page or online manual
for more information on the
To import MyPing, change directory to the location of the downloaded MyPing directory and type the following command (the example assumes MyPing was downloaded into your projects directory):
% cd ~/projects/MyPing % cvs import –m "Import of MyPing." MyPing example- program-myping myping_0
Finally, remove your local MyPing directory and check out the imported version:
% cd ~/projects % rm –rf MyPing % cvs co MyPing
Running Project Builder
One of the difficulties in getting Project Builder to work with a remote CVS repository is getting Project Builder to resolve your password. To accomplish this, you need to launch Project Builder from the right environment. There are two techniques for achieving this: running Project Builder from a shell with the right environment variables set, or using the SSHPassKey program. We will use the open method, but if you prefer, you can use the SSHPassKey program.
To get Project Builder to resolve your password:
- Make sure you set your environment variables correctly, as described in the Setting up CVS section.
- Open a shell in the Terminal, enter your passphrase, and enter the
% cd ~/projects/MyPing % open /Developer/Applications/Project\ Builder.app/ MyPing.pbproj
open command launches Project Builder as if you had double-clicked
the file's icon, but within the right environment. Now, Project Builder
can connect to the repository and resolve your password for accessing
files. Note the Project Builder status bar, which now indicates its
connection to the CVS repository.
Project Builder’s CVS Integration
One of the first differences you will notice when Project Builder is connected to a CVS repository is that the Groups & Files list contains a new column, with a CVS icon. This indicates that Project Builder recognizes the project is under version control.
Project Builder uses this column to display the status of your files. The following table shows the meaning of the status information character.
|C||File merged, changes|
|G||File merge successful|
|N||New file added|
|O||File checked out|
|U||File exists in repository, new revision created|
|W||File removed from entries file|
|?||File not in repository|
|-||File, or folder, is not in repository|