We bought the (excellent) book "Open Source Development with CVS" (see http://cvsbook.red-bean.com)

Based on that book, here is a list of cvs tricks that my co-workers may find useful (they already know cvs, so I am going to be terse).

Note: I'm supposing that the cvs project you're working on is called "source".

Preventing carpal when using cvs

This is the .cvsrc in my home directory

diff -u update -d -P cvs -q

Show log for a particular branch

Doing a log for a file is confusing if you have a lot of branches. Mostof the time you want to see only the log of a certain branch. This can be done for branch "a-branch":

cvs log -ra-branch file

Notice there is no space between "-r" and "a-branch".

To see logs only for the main trunk do:

cvs log -b file

Reverting to an older revision

Actually undo a commit must be done by checking in the reverted file. Suppose you want to undo the changes made between 1.3 and 1.5.

cvs up -j 1.5 -j 1.3 foo.c

This will retrieve the patch between 1.5 and 1.3, and apply it to "foo.c". Check the changes made to "foo.c" and commit.

Doing a merge repeatedly

You have two branches B1 and B2, on both the branches there is active development, but the changes made on B1 must be merged to B2 on a regular basis.

We're going to do merge N (the last merge was M=N-1).

  1. Tag the branch B1 so next time you'll know what you did merged already:

    cvs rtag -r B1 tag-merge-to-B2-N source
    Notice we created a release not a branch (no -b option).
  2. create the source of branch B2 in the directory B2

    cvs co -d B2 -r B2 source
  3. Merge in the changes made since merge M

    cd B2; cvs up -j tag-merge-to-B2-M -j tag-merge-to-B2-N

    The first time, it may be that you do not have tag-merge-to-B2-0 available (or something equivalent). Just leave out the first -j option and cvs will automatically do the right thing, using the point where B1 and B2 branched of.

  4. Check the changes made to the sources in B2 and commit it.

Note: it is in general a good idea to also create a tag when creating a branch.