fluidthoughts developers' guild

fluid funk

howto / cvs / basics

Basic CVS commands:

[ checkout | add | commit | update | diff | remove | export | rtag ]

cvs checkout

In order to start working with a CVS module, you'll need to checkout your own copy. This grabs the latest versions of the files in the library, and makes a local copy of them. This copy is commonly referred to as your repository. Only you should do work in your repository - and use CVS to manage the changes from other developer's repositories.

By default, the module will be checked-out into a directory with the name of the module. You can override this by specifying a location in the command line arguments.

cvs co modulename			#check out this module 
cvs co -d my_working_dir/ modulename	#check this out to a directory

The modulename is not optional.

cvs add

Perhaps your module needs some additional files. If you simply create a file inside your repository, it won't be a part of the CVS module. It will be pretty much ignored until you choose to add it. Once added and committed, others will get that file when they update.

$ cvs add extract.pl
cvs server: scheduling file `extract.pl' for addition
cvs server: use 'cvs commit' to add this file permanently

The filename is not optional, but you may use '*' to add everything in that directory branch.

If you are working with binary files, such as an image, audio, video, or class file - you'll need to add your files slightly differently to prevent keyword-expansion from ruining your file.

$ cvs add -kb myimage.gif

cvs commit

weeping willow If a file in the module needs a change, it should be done on the copy in your repository. As that edit might not be final, and could potentially break a feature for someone else working on the project, changes are not added to the library automatically. You must tell CVS that you approve the local edits, and commit the changes.

$ cvs commit -m "add extract script" extract.pl
RCS file: /home/cvs/modulename/extract.pl,v
done
Checking in extract.pl;
/home/cvs/modulename/extract.pl,v <-- extract.pl
initial revision: 1.1
done

The filename is optional. If nothing is specified, then all directories under the current branch will be examined for changes.

cvs update

One of the main benefits of using CVS is being able to grab the latest changes. This can be from other developers, or to make your website live.

You can just do the generic update command, which updates the files in the current directory, or add some more flags to make the command more useful:

$ cvs update filename
$ cvs -q update -dP
M keywords.html
? tagging.html

I highly reccomend using the last command several times a day, and always before you start a coding session.

The -q flag means that it goes into quiet mode (as opposed to verbose) This tells cvs not to report that it has checked each directory for changes. The -d flag tells it to grab new directories, and -P means "prune", or delete things that have been cvs removed, or have been deleted (renamed) in the master repository. There is one unexpected side-effect to this, the prune command removes empty module directories from your repository.

As shown above, the filename is optional.

Update flags

Depending on the state of your code and the central repository, various things can happen. For each file that is not in sync with the master repository, a flag is thrown, and an action can be done to that file, or not touched.

  • (no flag) - file is up to date
  • M - locally modified
  • A - locally added
  • U - entire file has been updated
  • P - local file has been patched with changes
  • C - your version conflicts with changes that you have't grabbed yet in the central repository
  • ? - file has not been added to module
  • R - marked for removal, but not yet committed

cvs diff

As development work progresses on a file, it's differences with the library version grow. As it's useful to include meaningful comments in a commit statement, it's also useful to know how the file has changed.

$ cvs diff basics.html 
Index: basics.html
===================================================================
RCS file: /home/cvs//fluidthoughts/howto/cvs/basics.html,v
retrieving revision 1.5
diff -r1.5 basics.html
137
>               Check the differences

The filename is not optional.

cvs remove

$ cvs remove filename
$ cvs remove -f filename

Sometimes, files are no longer needed in the project, and removing it would make everyone's workspace cleaner. This can be done using the cvs remove feature. CVS keeps track of every file you've entered, even after you decide to get rid of it. So this doesn't entirely remove the file permanently, as it is stored in a special file in the CVSROOT named the Attic.

The filename is not optional.

cvs export

The export command is used when you're intending to give the codebase to another developer, but without the CVS administrative directories.

cvs export -r tag module

Note: there is a bug in many versions of CVS that will prevent you from exporting a module if your CVSROOT variable has a trailing slash. It will give you this error:

$ cvs export -r HEAD module
cvs [export aborted]: cannot export into working directory

Simply remove the trailing slash from your CVSROOT environment variable and issue the export command again

$ export CVSROOT='/home/cvs'
$ echo $CVSROOT
/home/cvs
$ cvs export -r HEAD module

cvs rtag

cvs rtag -F tagname modulename

example:

cvs rtag -F aaff-1_0-beta1 aaff

 

[ checkout | add | commit | update | diff | remove | export | rtag ]

 

$Id: basics.html,v 1.12 2005/03/02 20:31:53 willn Exp $

CVS - Concurrent Versioning System