CVS

General CVS Set Up

Make sure that this is in ~/.bashrc.

export CVSROOT=/home/chris/cvsroot

For remote CVS use, put these in the .bashrc:

export CVSROOT=:ext:xed@$XED:/home/xed/cvsroot/
export CVS_RSH=ssh

Source your .bashrc if echo $CVSROOT produces nothing.

$ . ~/.bashrc

Go to the repository.

$ cd $CVSROOT

Set it up while in the repository dir. Only do this once for a new place for CVS to store stuff.

$ cvs init

Go back to the directory you were interested in archiving.

$ cd -

Optional Check out the config CVS file to have a look This can go anywhere and you can make modifications to the config files that are stored by CVS. Do an update to make changes take effect.

$ cvs co CVSROOT
$ cvs release CVSROOT/
$ rm -r ./CVSROOT*

Start Using CVS On A Project - Directory Of All Good Files

Go to where the source code is. Here imagine that the source is being kept in a series of directories that get copied every week (a crude RCS).

$ cd ~/software/GeoGad.050423

Set up project (i.e. "module"). This must be done from the project’s directory. All files in the current directory will recursively be tracked. The module name is "GeoGad". Here "XedTech" is a "vendor tag". Here "START" is a "initial tag".

$ cvs import GeoGad XedTech START

After creating a module, the files involved have to be checked out before they can be properly used by CVS. This makes a new directory called GeoGad so you might have to go up a directory if you want to to have the CVS version repopulate the GeoGad directory you’re already in.

$ cd ..
$ cvs checkout GeoGad

Intend To Use CVS Before Writing Anything - No Files Exist

To set up a module in CVS before any source code is written, use any empty directory.

$ mkdir nothing
$ cd nothing
$ cvs import nova XedTech START
$ cd ..
$ rmdir nothing

Go to where you want to work on this project.

$ cd ~/funnewprojects

Get a CVS ready directory (called "nova") to work in.

$ cvs co nova

Change to this directory, create files and then "cvs add" them.

$ cd nova

Have A Nasty Untracked Mess - Some Files Good Some Bad

Imagine a project that’s a total mess, some files in the directory are backups done by hand and therefore shouldn’t be part of a CVS import. Start by moving the directory so that you can use this name for a new and improved CVS version:

$ mv /projects/jcsg/typical /projects/jcsg/typical.orig

Make a new empty version of the directory:

mkdir /projects/jcsg/typical

Go to that directory:

$ cd /projects/jcsg/typical

Copy in the files that need to be there; leave the bogus stuff.

$ cp ../typical.orig/wheelinvention.pl .

Make a CVS project out of it:

$ cvs import typical JCSG START

Make the source directory a working CVS directory:

$ cd ..
$ cvs co typical

Optionally delete the original directory:

$ rm -r ./typical.orig

Adding Files

To add files to the CVS module, set it up for addition and when a commit is done the file will be tracked too.

$ vi Makefile
$ cvs add Makefile
$ cvs commit

Deleting files from CVS’s control is similar to add.

$ rm planningnotes.txt
$ cvs delete planningnotes.txt
$ cvs commit

Before doing anything that might have been touched by other developers (or you from somewhere else), it’s important to make sure you are working with the latest versions. The -d will create any new files that don’t exist on your current version. $ cvs update -d

Using CVS From A Remote System

Put this in the .bashrc (assumes $XED is defined as the IP#)

export XCVSROOT="xed@$XED:/home/xed/cvsroot"

Check out like this:

[catalyst][~/xfile/python]$ cvs -d $XCVSROOT co bildam

Renaming A CVS Project

If you start a project with a certain name, but later think of a better one, then you need to change the CVS name. There are other ways to do this, but this is pretty safe. Go to the CVSROOT directory where this project lives. Then make an exact copy to the new name:

cp -va jerkcontrol guestrelations

Go back to your working directory and:

cvs co guestrelations

Start using it. If everything is ok, then you can delete the old working directories and the old version in CVSROOT:

rm -r $CVSROOT/jerkcontrol

Note that there may be some references to the old project in the history file of $CVSROOT/CVSROOT.

CVS Keywords

The following keywords can be embedded in source code files and will get expanded into something more meaningful. The format is

$Keyword:$

Replace "Keyword" with one of these:

  • Author

  • Date

  • Header

  • Id

  • Log

  • Locker

  • Name

  • RCSfile

  • Revision

  • Source

  • State

Personally I use $Date:$ and $Revsion:$ which seem the simplest and most useful.

SUBVERSION

Create A Repository

$ sudo mkdir /aleph1/svn $ sudo chmod 770 /aleph1/svn $ sudo svnadmin create /aleph1/svn $ sudo chgrp -R aleph1 /aleph1/svn $ sudo chmod -R g+rw /aleph1/svn/db /aleph1/svn/locks

Note- I did all of this already so normal users can jump right to the next step.

Creating A SVN Virtual Directory

SVN keeps track of stuff as if it was in a special file system. You can customize the contents of this file system. For example, you might want to start with a sub directory for all your projects:

$ svn mkdir file:///aleph1/svn/xed -m "Software that Chris is managing."
Committed revision 1.
$ svn ls file:///aleph1/svn/
xed/

And then you can start an empty project if you’re about to embark on one with no pre-existing files:

$ svn mkdir file:///aleph1/svn/xed/chnotify -m "Monitor the file system for changes."
$ svn co file:///aleph1/svn/xed/chnotify
$ ls -a chnotify
. .. .svn

Notice that you’ve created a directory in the virtual svn file system and then checked it out to a place in the real file system. Doing it in this way is important because now the directory in the real file system is trackable by Subversion as indicated by the existence of the .svn housekeeping directory.

Importing A Project

If you already have a bunch of files under development and want to begin tracking them all with svn, use the "svn import" command. This will take an existing directory tree and install it into Subversion management:

$ svn import -m "chnotify- Tracks file system changes" \
/home/xed/xfile/project/programming/bash/chnotify/ \
file://localhost/aleph1/svn/xed/chnotify

This does not make the existing directory understand Subversion, however. This just allows subversion to get some files. To have Subversion be able to care for files you can actually work with, you have to check the import back out.

Starting From Scratch and Adding Files

If you’ve started with the intent to use Subversion from before your project has any files, you need to add the files to the repository. Do this by:

$ vi chnotify.py
$ svn add chnotify.py -m "First sketch of program."
A        chnotify.py
$ svn ci
Adding       chnotify.py
Transmitting file data .
Committed revision 3.

The "svn add" tells Subversion that you want this file to be tracked. The "svn ci" commits your addition. Before doing the commit, someone else doing a checkout wouldn’t see this.

Checking Out A Project

$ svn co file:///aleph1/svn/xed/chnotify

Editing And Committing The Files

Change some things. For example:

$ vi libchnotify chnotify

Now that some files have been edited, it’s best to see if there are any conflicts, i.e. did some other user make the same changes while you did?

$ svn update
$ svn ci -m "Just some sample changes."

Using SVN Remotely With SSH

From the remote machine (for example, princeton):

$ svn co svn+ssh://lj/aleph1/svn/chnotify

(lj is a host alias for lajolla, see /etc/hosts)

Finding Log Info

Hopefully you’ve been in the good habit of describing your check ins with a little descriptive statement using "-m". That wouldn’t be very useful if you couldn’t do anything with that. Here’s how to review it: $ svn log chnotify.py