17.5. Installing and Using cvs

The cvs utility may already be installed on your system (you can check by typing cvs). If not, you can download a source or binary package from http://www.cyclic.com.

Before using cvs, you need to set the environment variable CVSROOT to point to the KDE CVS server. If your CVS login name is janedeveloper, for example, you should set CVSROOT to


   1 
   2 :pserver:janedeveloper@cvs.kde.org:/home/kde
   3 

17.5.1. Frequently Used Commands

The cvs utility is flexible and thus offers many options. Common operations performed with cvs are listed in the following paragraph. The option -z6 is included in all the commands. It enables compression of the information to be transferred between the server and the client. This can speed up transfers, especially over slow connections.

In the following list, modulename refers to one of the module names listed earlier in this chapter (kdesupport, kdelibs, and so on) and BRANCH_NAME refers to one of the CVS branches (for example, HEAD). Unless otherwise stated, the option -r BRANCH_NAME is optional. If it is omitted, the default branch will be used. Within each module may be several applications or libraries, with one stored per subdirectory. In the following, appname refers to one of these subdirectory names. For example, the module kdeutils contains the subdirectories kjots, kedit, and kwrite (among others) which contain the respective applications.

Unless otherwise noted, all commands given in this section assume that you want to use the current working directory for your local copy of CVS source code.

17.5.1.1. Check Out a Module


   1 
   2 cvs -z6 co -r BRANCH_NAME modulename

copies modulename to a local subdirectory of the same name (which cvs creates, if necessary).

17.5.1.2. Commit Changes


   1 
   2 cvs -z6 commit

updates the CVS repository so that it matches your local code. In this case, the code in the current directory and its subdirectories will be updated. To commit a specific file or subdirectory, use


   1 
   2 cvs -z6 commit filename

or


   1 
   2 cvs -z6 commit subdirectory

You should be sure that your code compiles and runs before committing it to CVS. This way, other developers will always have a running version of KDE to work with.

17.5.1.3. Update a Previously Checked-Out Module


   1 
   2 cvs -z6 update modulename

or


   1 
   2 cvs -z6 update modulename/appname

updates your local code to match the CVS. If you use this regularly, you can keep up-to-date with CVS with minimal file-transfer time because only the differences between your local code and the CVS are transferred.

17.5.1.4. Check Out a Single Application from Within a Module


   1 
   2 cvs -z6 co -l modulenamecvs -z6 co modulename/appnamecvs -z6 co -l admincd modulename; ln -s ../admin

The option -l tells cvs not to recurse the subdirectories. Thus, in the first line, only the module-level Makefile, configure script and related files will be copied to the local disk. The second line copies only the subdirectory containing the application we are interested in. The admin module contains more configuration scripts and is used by all other modules. When a module is retrieved in its entirety, the admin directory is included as a subdirectory of the module. Here, it is placed instead at the same level as the module's directory. Therefore, in the last line, we make a symbolic link to admin in the module's directory.

17.5.1.5. Add a File


   1 
   2 cvs add mynewcode.cppcvs -z6 commit

adds the file mynewcode.cpp to CVS. Simply creating the file and running a commit is not enough! Doing this will update all the files you have changed, but it will not include new files. This means that, typically, the application will be broken in CVS. Be sure to add your new files. (Don't use -z6 when adding, because add makes only local changes; it marks the file as "to be added.")

17.5.1.6. Remove a File


   1 
   2 rm oldcode.cppcvs remove oldcode.cppcvs -z6 commit

removes the file oldcode.cpp from the current directory and then from CVS.

17.5.1.7. Add a Directory


   1 
   2 cvs add newdircvs add newdir/newsource.cppcvs -z6 commit

adds the directory newdir and its source file newsource.cpp to CVS. Note that you need to do cvs add newdir/newsource.cpp for each source file before committing. You cannot add an empty directory.

17.5.1.8. Remove a Directory

First, remove all files in the directory from CVS as described previously in "Remove a File." Then,


   1 
   2 cd ..cvs -P update

removes the directory from CVS and from your local disk.

17.5.1.9. List CVS modules

This cannot be done directly with cvs, but you can get a good approximation of a list of all the modules by typing


   1 
   2 cvs -z6 co -c