“This should be fairly easy and straightforward” I thought to myself when I first started looking at trying to do away with using MacCVSClient to manage collaborative CVS based projects. It bothers me because (a) it’s slow when dealing with large projects and (b) it uses a proprietary binary format for the CVS information files.
In the end it was a fairly simple procedure but I found myself running in circles trying to decipher information from various sources and turn it into something cohesive that was clear enough to a CVS newbie such as myself. Hence this tutorial, which will hopefully grace the Google archives for some time and save others the same frustrations I suffered trying to get this to work.
A Few Assumptions
Although this tutorial is intended for Mac OS X users, the majority of it applies to any Unix-based operating system which can run the bash
shell (the default shell in Mac OS X). BBEdit is only available on the Mac though so that portion is of limited widespread appeal.
I’ve purposing left out things related to other shell environments to keep the article length down, but if anyone is stuck there and wants to know how to do this using other shells, drop a note in the comments and I’ll post some additional information or point you to where to get it.
Setup Your Environment
To save yourself some work you will want to set some environment variables to simplify interacting with the CVS binaries. To do this, fire up the Terminal application and type pico .bash_login
to create a new file (or edit an existing one) in your home directory.
The first variable to set is CVSROOT
which is used to indicate the location of your repository. Assuming you’re dealing with a CVS server running on a second machine and being authenticated using the pserver method, that variable would look like:
export CVSROOT=:pserver:USER@IP_ADDRESS:/DIRECTORY/PATH/TO/REPOSITORY
An example might look like:
export CVSROOT=:pserver:scott@www.myserver.com:/Volumes/Working/cvsrep
The second variable that you may need to set is CVS_CLIENT_PORT
, though unless you need to use a port other than the default (2401), you can probably skip this step. If you are using a Firewall (hardware or software) make sure to allow traffic through this port.
export CVS_CLIENT_PORT=2401
The third variable is the CVS_PASSFILE
which also is optional but useful if you want to store your unencrypted CVS password somewhere other than the default location in your home directory. Keep in mind that the pserver method sends data in plain text format so it’s possible that it could be read if intercepted by unauthorized parties — both your account information and the repository data itself. For details on improving this situation, see the Bonus Tip below.
The name of the file by default is .cvspass
. The information for the CVS_PASSFILE
variable should look like this:
export CVS_PASSFILE=~/.cvspass
The last variable we need to be concerned with setting is the CVS_EDITOR
variable. Since we’re going to be using BBEdit for managing CVS, you can set this option to use the bbedit
shell command instead of another CLI-based text editor such as vi
or pico
.
Save the changes to your .bash_login
file by pressing Control-O to save the file. To apply the changes to your shell, either open a new Terminal window or, in the current window, type source .bash_login
which will reload your shell and associated environment variables.
You can check that the new variables are set by typing env
which will output a list of all the available environment variables. Assuming the new variables are set, you are set to login to the CVS server and checkout a project.
Caveats
The big caveat with this procedure is that you need to login to CVS via the Terminal or a BBEdit worksheet to perform any actions with its CVS tools. If you’re adventurous you could easily write an AppleScript/Perl or Shell script that will do that work for you and make the process easier, but if you aren’t, then just type login cvs
and then enter your CVS user password (if you have one).
Keep in mind that many public CVS servers such as those at SourceForge typically provide anonymous access without the need for a password. You can get the full scoop in the case of SourceForge at their site.
The second caveat, and I’m not sure how much this still applies on Panther and with newer versions of BBEdit but you may also need to create a special environment file specifically for GUI apps to use since they can’t inherit these from the shell.
There are two ways of doing this — either through the command line (by creating a file named environment.plist in a new hidden directory in your home folder called .MacOSX
), or you can go the easier route and use RCEnvironment which is a preference pane which provides a GUI for creating and editing this file. Unless you know what you’re doing, I’d suggest using the GUI to get started.
Be sure to logout and login again to make the variables available in the GUI environment.
Bonus Tip
Let’s say you want to ensure that all your CVS-related traffic is tunnelled through SSH, all you need to do is add one more line to your .bash_login
file and make a small change to your CVSROOT
environment variable. That additional line looks like this:
export CVS_RSH=ssh
The revised CVSROOT
variable should use this format:
export CVSROOT=:ext:USERNAME@IP_ADDRESS:/PATH/TO/REPOSITORY
You should not have to login, but you will be prompted for your password each time you launch a new Terminal session.
Additional Information
Here’s a few additional links for everyone’s benefit (myself included). I will likely revise this tutorial at some point, but until then let me know if something doesn’t work for you or if there is anything notable that appears missing or incorrect.
So say you…
Did you feel that breeze? It was this entire post going over my head. Sometimes I feel so… uninformed.
Dave July 23, 2004