This docuement is a summary of common CVS usage, see cvs(1) for details. Please read the man page to make sure we are talking the same language.
The repository for CVS is kept under $CVSROOT and is just the same tree hierarchy containly the RCS revision (,v) files.
Most people do not need to know any of this - but it can be handy.
$ cvs checkout namedwould check out $CVSROOT/named/* into ./named after which you can start editing to your hearts content.
Normally though you just want to commit your changes to the same branch that you checked out. You simply:
$ cvs commit -m'a useful comment decribing the change' file1 ...If file1 etc are omitted, then all changed files under the current point in the tree are committed. If the comment is omitted, you will be dropped into $EDITOR to provide one.
$ cvs diff -cbto see all the changes you have made in your copy of the tree. If you nominate one or more files on the command line only those files will be diff'd. You can do fancy things like:
$ cvs diff -cb -r1.2 file1 $ cvs diff -cb -D yesterday file2would show the diffs between the current version of file1 and version 1.2 of the same file then show the changes made to file2 since yesterday. See cvs(1) for all the details on date_spec. In addition you often want to see the commit comments that have been made.
$ cvs log file1will display the commit history of file3, so you see why the changes since version 1.2 were made. In some environments, changes cannot be committed into CVS without a change docket, and these are recorded against the change and therefor show up in the log.
$ cvs add newfile $ cvs commit -m"explain why I added newfile" newfile
$ rm file6 $ cvs remove file6 $ cvs commit -m"why I removed file6" file6The file is not actually deleted from the repository, it is moved into the Attic (incase someone wants to restore it later). To truely delete the file, use delete instead of remove, but be very very sure that is what you want (usually it is not).
Whenever appropriate - such as when you have no outstanding changes and want to start editing something run:
$ cvs updateWhich will ensure that you have an up to date copy of the tree. It will also warn you about files you have modified, created and not added etc.
It is therefore vitally important to pay attention to what CVS says.
$ rm file1 $ cvs update
$ co -p1.2 `cat CVS/Repository`/file1,v > file1 $ cvs diff file1 $ cvs commit -m"reverted to version 1.2 which worked" file1The -p1.2 option to co tells it to check out version 1.2 of file1 to stdout. The CVS/Repository file contains the location of the rcs files (,v) for the working directory.
$ cvs diff -cb -r1.1 -r1.2 file1 > diffs $ patch -R < diffsIn the above example, diffs contains the changes from version 1.1 to 1.2, the patch command is then used to apply the diffs in reverse (-R). If patch succeeds, then the offending change has been successfully removed and file1 can be committed.
The patch may fail to apply though if subsequent changes cause conflicts. In which case patch will create a file1.reg file which contains the patches that it could not apply. Time for some hand editing.