Sean’s Obsessions

Sean Walberg’s blog

Starting Out With CVS

As often as I use CVS, I can never remember how to start a new project from an existing code base. Invariably, I look in the man pages and on the web, and read through several pages to get what I want. Here is the way to do it.

The goal here is to take some existing code, put it under source control, and then set it up so you can begin checking it back in. We import, delete, then check out to do this:

The example uses a project called “rs232”

Make sure $CVSROOT is set:

1
2
$ echo $CVSROOT
/export/home/CVS

(if not, set it, then “cvs init”)

Get into the directory with the code:

1
2
3
4
$ pwd
/export/home/sean/rs232
$ ls
Makefile  rs232.asm  rs232-poll.asm

Import the code into CVS:

1
$ cvs import rs232 VENDOR HEAD

You’ll be prompted to make a comment, I usually use “Initial import” You’ll then see the files being created (the ‘N’ at the left column)

1
2
3
4
5
"/tmp/cvsY0a2zz" 5L, 244C written
N rs232/Makefile
N rs232/rs232-poll.asm
N rs232/rs232.asm
No conflicts created by this import

So, now the CVS repository is created:

1
2
3
4
5
$ ls -l $CVSROOT/rs232
total 16
-r--r--r--    1 sean     users         530 Nov  3 08:27 Makefile,v
-r--r--r--    1 sean     users        6347 Nov  3 08:27 rs232.asm,v
-r--r--r--    1 sean     users        3799 Nov  3 08:27 rs232-poll.asm,v

Since I’d like to continue editing the code where it is, delete the working directory and check it out (or, we could have moved the original files to a tempdir)

1
2
3
4
5
6
7
8
9
10
$ cd ..
$ rm -rf rs232/
$ cvs co rs232
cvs checkout: Updating rs232
U rs232/Makefile
U rs232/rs232-poll.asm
U rs232/rs232.asm
$ cd rs232
$ ls
CVS  Makefile  rs232.asm  rs232-poll.asm

Make your changes, then use cvs ci to check in.

Comments

I’m trying something new here. Talk to me on Twitter with the button above, please.