A sample session

As a way of introducing cvsnt, we'll go through a typical work-session using cvsnt. The first thing to understand is that cvsnt stores all files in a centralized repository (Chapter 2, The Repository); this section assumes that a repository is set up.

Suppose you are working on a simple compiler. The source consists of a handful of C files and a Makefile. The compiler is called tc (Trivial Compiler), and the repository is set up so that there is a module called tc.

Getting the source

The first thing you must do is to get your own working copy of the source for tc. For this, you use the checkout command:

$ cvs checkout tc

This will create a new directory called tc and populate it with the source files (the commands used may be slightly different on Windows machines, but the output is the same).

$ cd tc
$ ls
CVS         Makefile    backend.c   driver.c    frontend.c  parser.c

The CVS directory is used internally by cvsnt (on Windows clients it is normally hidden). Normally, you should not modify or remove any of the files in it.

You start your favorite editor, hack away at backend.c, and a couple of hours later you have added an optimization pass to the compiler. A note to rcs and sccs users: There is no need to lock the files that you want to edit. Chapter 11, Multiple developers, for an explanation.

Committing your changes

When you have checked that the compiler is still compilable you decide to make a new version of backend.c. This will store your new backend.c in the repository and make it available to anyone else who is using that same repository.

$ cvs commit backend.c

cvsnt starts an editor, to allow you to enter a log message. You type in "Added an optimization pass.", save the temporary file, and exit the editor.

The environment variable $CVSEDITOR determines which editor is started. If $CVSEDITOR is not set, then if the environment variable $EDITOR is set, it will be used. If both $CVSEDITOR and $EDITOR are not set then there is a default which will vary with your operating system, for example vi for unix or notepad for Windows NT/95.

When cvsnt starts the editor, it includes a list of files which are modified. For the cvsnt client, this list is based on comparing the modification time of the file against the modification time that the file had when it was last gotten or updated. Therefore, if a file's modification time has changed but its contents have not, it will show up as modified. The simplest way to handle this is simply not to worry about it--if you proceed with the commit cvsnt will detect that the contents are not modified and treat it as an unmodified file. The next update will clue cvsnt in to the fact that the file is unmodified, and it will reset its stored timestamp so that the file will not show up in future editor sessions.

If you want to avoid starting an editor you can specify the log message on the command line using the -m flag instead, like this:

$ cvs commit -m "Added an optimization pass" backend.c

Cleaning up

Before you turn to other tasks you decide to remove your working copy of tc. One acceptable way to do that is of course

$ cd ..
$ rm -r tc

but a better way is to use the release command (the section called “release--Indicate that a Module is no longer in use”):

$ cd ..
$ cvs release -d tc
M driver.c
? tc
You have [1] altered files in this repository.
Are you sure you want to release (and delete) directory `tc': n
** `release' aborted by user choice.

The release command checks that all your modifications have been committed. If history logging is enabled it also makes a note in the history file. the section called “The history file”.

When you use the -d flag with release, it also removes your working copy. The -f tells cvsnt to also delete unknown files (such as object files).

The release command always finishes by telling you how many modified files you have in your working copy of the sources, and then asks you for confirmation before deleting any files or making any note in the history file.

You can decide to play it safe and answer n RET when release asks for confirmation.

Viewing differences

You do not remember modifying driver.c, so you want to see what has happened to that file.

$ cd tc
$ cvs diff driver.c

This command runs diff to compare the version of driver.c that you checked out with your working copy. When you see the output you remember that you added a command line option that enabled the optimization pass. You check it in, and release the module.

$ cvs commit -m "Added an optimization pass" driver.c
Checking in driver.c;
/usr/local/cvsroot/tc/driver.c,v  <--  driver.c
new revision: 1.2; previous revision: 1.1
done
$ cd ..
$ cvs release -d tc
? tc
You have [0] altered files in this repository.
Are you sure you want to release (and delete) directory `tc': y