Your projects are done in groups of 2. Both of you will be
creating, deleting, modifying different parts of the project code as the
semester goes. The question is, what is the best way to manage your
code base? Here are some of the things you may want to consider:
After you break down the files, you should think about how to manage the files so that they can be separable, consistent, reversible, and collision-free. We list three approaches below, with varying degree of complexity. You should discuss with your partner how you will manage the code. Our recommendation is that you use RCS.
To setup your working directory, first put all of your files in common dir, and then
cd user1 # cd to your working dir ln -s ../common/* . # soft (symbolic) link all the files in common dir to your dirTo modify a file, make a copy of the file from common dir to your working dir:
cd user1 cp ../common/<file> ./When you are ready to make your file visible, copy that file from your working dir to common
cd user1 cp <file> ../common/If you want to give up the ownership of <file>, remove <file> from your working dir, and make it a soft link. Thus, if your partner later puts update of <file> in common dir, you will automatically see the change.
cd user1 rm <file> # remove your ln -s ../common/<file> <file> # make this file in your working dir a soft linkNow if you want to make backup, just make a copy of common (and possibly your working directories) to backup dir, such as
cd <project dir> cp -r common backup/common.0305 # common dir backup on March 5
1. Create your RCS directory and two working directories. You can choose the names of <user1> and <user2>.
cd <project dir> mkdir RCS <user1> <user2> cd <user1> ln -s ../RCS . cd ../<user2> ln -s ../RCS .Now each of you has a working directory.
2. Prepare your files: copy all of the source code you have into <project dir>/<user1>, which contains Makefile, some .c and .h files. First, you should add the following headers to the beginning of your source files:
/* $Id$ * $Log$ */
# $Id$ # $Log$These header fields will be automatically filled in every time you "check-in" your code to RCS. It will show who and when the modification occurred for the files.
3. Insert files to the RCS repository:
cd <user1> ci -u -m"<log message>" *.c *.h MakefileFollow the direction and enter the description of each file. When you are done, the RCS repository has the initial version of the files, and user1 dir has a read-only version of the source code.
4. Set up your partner's directory (user2)
cd <user2> cp ../user1/*.c ../user1/*.h ../user1/Makefile . co -r *.c *.h MakefileNow your partner (user2) also has a read-only version of the source code.
5. When you (user1) want to edit <file>, you need to first check out <file> by doing
cd <user1> co -l <file>"-l" option locks <file> in RCS (so that your partner cannot edit it), and it sets the permission of <file> in your local directory read/write, so you can edit it.
6. When you are done, check in <file> by doing
ci -u -m"<log message>" <file>"-u" returns the lock back to RCS (so that your partner can later acquire the lock if needed). It sets the permission of <file> in your local directory read-only.
7. Important: when your partner makes a file update to RCS, you don't get that update automatically, unless you explicitly "check out" that file. So every once in a while, you should do
co -r <file> # if you know exactly which file you want to update or co -r * # if you want to update all filesIf you are currently modifying a file, "co -r" will not automatically replace that file. It would prompt you whether you want to delete your local copy, and you can just say "no".
8. There are many other useful functionalities in RCS. We encourage you to explore rcsdiff, which allows you to compare different revisions. "co -d<date>" allows you to retrieve a snapshot of code on a selected date. There are also ways to tag a snapshot of code.
It is very important to know that once you check out a file, you hold a lock on the file. Your partner will NOT be able to modify, until you check in the file again. So check out the files only when you need to edit it, and when you are done editing, check it in again.
You should put only the important files under RCS control, such as *.c, *.h, and Makefile. You should not put .o files or temporary test cases under RCS, for example.
For more information about RCS, read the man page (man rcs, man
ci, man co). Also I find this RCS
tutorial helpful.