Class 13: Version Control


Reading
Read Chapter 4 of The Art of Unix Programming. It's the first chapter on Raymond's section on design, and it talks about modularity. We're going to start thinking about a new project Monday, and I'd like you to think of some of these things when we set out to make our design.

Homework
Get a PRCS project up for your Project 1. Try adding a few whistles and bells for fun and see how the version tracking works. If you read the documentation you should be able to figure out how to change the major version numbers too,m so you can go from 0.4 to 1.0.


Design in Unix
We went over Raymond's "rules" and how we saw bits and pieces of them relate to our Project 1.

What made things difficult
You pointed out various things that got in the way of development in Project 1. First of all, projects often lacked clear interfaces ... or consistent interfaces. Things would be changed and you never knew if you had the most recent, up-to-date version. Second of all, distributing code was an issue. Sharing code between parteners working on the same project was also a problem.

Version Control
Version Control System can take care of a lot of the problems that cropped up in Project 1. We talked about the PRCS system and I gave a quick demo.

PRCS
PRCS (documentation) is an easy-to-use version control system. Right now I have it set up on an account of mine. We'll all be using the same repository to. To make sure that your shell finds PRCS and that PRCS uses the right repository, put the following in your .cshrc file:
    setenv PATH ${PATH}:/home/qepcad/bin
and
setenv PRCS_REPOSITORY /courses/wcbrown/PRCS
Now, suppose you want to checkout an existing project ... say cth. You create a directory that you want all the project files to be brought into, and you enter:
prcs checkout cth
All the cth files from the most recent version of cth will end up in that directory, and you can simply type make to create the program. Now, if you make some changes to the project and you'd like to submit it as a new version of cth, you

  1. edit the cth.prj file to add the "New Version Log" entry for the changes you've make
  2. checkin your new version:
    prcs checkin cth
  3. checkout the project to update all your files to reflect changes in version number, etc.
    prcs checkout cth

To get information on the various versions of cth, enter:
prcs info -l cth
It'll tell you what the different versions are, when they appeared, and even what kind of things changed from version to version.

The PRCS .prj File
When you have a PRCS project checked out, the file <projname>.prj acts as the accounting document for the project. It's a manifest of all the files encompassed by the project, and includes version information, etc. Here's the file cth.prj:
cth.prj
;; -*- Prcs -*-
(Created-By-Prcs-Version 1 3 0)
(Project-Description "A Coin-toss-game simulator.")
(Project-Version cth 0 4)
(Parent-Version cth 0 3)
(Version-Log "Created full path to pp program")
(New-Version-Log "")
(Checkin-Time "Fri, 11 Feb 2005 13:51:50 -0500")
(Checkin-Login m057206)
(Populate-Ignore ())
(Project-Keywords)
(Files
;; This is a comment.  Fill in files here.
;; For example:  (prcs/checkout.cc ())

;; Files added by populate at Wed, 09 Feb 2005 14:06:23 -0500,
;; to version 0.0(w), by m050000:

  (Makefile (cth/0_Makefile 1.1 600))
  (cth.cpp (cth/1_cth.cpp 1.4 600))
)
(Merge-Parents)
(New-Merge-Parents)
You see in red were the two files that make up the file are incorporated. If you want to add a file to the project, as opposed to simply modifying an existing file, you'd have to add a line for it. For example, if you added a cth.h file, you'd need to add the line
(cth.h ())
to cth.prj. Where it goes relative to the other files is unimportant. What's in parens after the filename is also unimportant. PRCS using that space for bookkeeping.

Creating a project for the first time
To create a PRCS project with name name from an existing project:
  1. Make sure all your files are in their own directory, and cd into that directory
  2. enter prcs checkout name. This doesn't check anything out, but it will create the skeleton of the name.prj file you need
  3. enter prcs populate to have prcs add entries for all the files in your directory to name.prj
  4. Edit name.prj to give it a Project Description, a New Version Log, and to add/delete any files from the lines automatically generated by populate
  5. Checkin your project with prcs checkin name
  6. cd to /courses/wcbrown/PRCS and change the permissions on your project directory there to g+rwx and on everything inside the project directory to g+rw. This will give all of you permission to checkout each other's projects, which is good, but also to add new versions, which could be bad. Be responsible.
The complete cth project - with automatic version number update
Go ahead and checkout cth. Look at how I get PRCS to generate the version number in my C++ code automatically using "$Format". This is a cool feature. You should use it too!


Christopher W Brown
Last modified: Fri Feb 11 16:16:15 EST 2005