r4 - 21 Feb 2008 - 19:16:27 - JohnPerkinsYou are here: TWiki >  CSDocs Web  > FileSharingAndCVSHowTo

Sharing Files/Using CVS

This document explains how to set up AFS groups for sharing files, and also how to use CVS for version control. This document was adapted from a CVS tutorial written by Colby O'Donnell (colbster@cs.wisc.edu), a former student in the department.

Creating The CVS Repository

To use CVS for version control, you need to create a repository, where the master copies of your files are kept. This only needs to be done once.

Colby first creates the CVS repository, which will live on his account.

alfred(1)% mkdir -p CVS/CVSROOT
alfred(2)% cd CVS/CVSROOT
alfred(3)% setenv CVSROOT `pwd`
alfred(4)% cvs init
alfred(5)% cd ../..
alfred(6)% cd cs/736
alfred(7)% mkdir cs736-p2
alfred(8)% cd cs736-p2
alfred(9)% mkdir doc src
alfred(10)% touch README Makefile Notes
alfred(11)% cvs import cs736-p2 ALFRED V_1_0_0

CVS looks at all the files in the current directory tree, and imports them into a new project called cs736-p2. ALFRED is a label for the vendor-tag while V_1_0_0 is a label for the release-tag. (See man cvs).

Setting Up AFS Groups For Sharing Files With Other Users

You want to set up a pts group to share files in your AFS space with other users.

First, Colby gives his cs736-p2 group write permission to the CVS repository.

alfred(8)% cd CVS
alfred(9)% ls -l

drwxr-xr-x 2 colbster 2048 Oct 12 15:59 CVSROOT
drwxrwxr-x 4 colbster 2048 Oct 12 16:07 cs736-p2

Colby's project group consists of himself, suan, and alexey. First, create an AFS group to represent cs736-p2 users:

alfred(10)% pts creategroup colbster:cs736-p2
alfred(11)% pts adduser colbster colbster:cs736-p2
alfred(12)% pts adduser suan colbster:cs736-p2
alfred(13)% pts adduser alexey colbster:cs736-p2
alfred(14)% pts membership colbster:cs736-p2

Members of colbster:cs736-p2 (id: -1056) are:
    suan
    alexey
    colbster

Now Colby sets the ACL (permission) for the CVS directories:

alfred(15)% afs_rseta CVSROOT colbster:cs736-p2 write
alfred(16)% afs_rseta cs736-p2 colbster:cs736-p2 write

Checking Out A Copy Of The Repository For Editing

Now each user in the cs736-p2 group can create a working directory (also called a "sandbox"), to edit or change project files. To check out a copy of the project tree, Colby first sets his CVSROOT environment variable with the command setenv CVSROOT /u/c/o/colbster/CVS.

Colby now creates his own working directory (as could alexey or suan).

alfred(17)% cd cs/736
alfred(18)% cvs checkout cs736-p2

This will create your cs736-p2 working directory as a subdirectory of your current directory, which only you have access to. CVS always knowns where the main repository is because of your CVSROOT environment variable. You can now safely edit files in your copy of the source tree without fear of your changes conflicting with other users' changes.

Adding New Files To The Repository

Suan is going to add the proposal.html file to the project. To do that, he would create an initial copy of the file in his home directory, and then:

siamese(1)% cd cs/736/cs736-p2
siamese(2)% ls -l

drwxr-xr-x 2 colbster 2048 Oct 12 16:07 CVS
-rw-r--r-- 1 colbster 0 Oct 12 16:07 Makefile
-rw-r--r-- 1 colbster 0 Oct 12 16:07 Notes
-rw-r--r-- 1 colbster 0 Oct 12 16:07 README
drwxr-xr-x 3 colbster 2048 Oct 12 16:07 doc
drwxr-xr-x 3 colbster 2048 Oct 12 16:07 src
siamese(3)% mv ~/proposal.html .
siamese(4)% cvs add proposal.html

The proposal.html file has been marked to be added at the next cvs commit.

Commiting Changes

If Suan wishes to commit only the added proposal.html file:

siamese(5)% cvs commit proposal.html

Or if Suan wants to commit all files recursively, starting from the current working directory:

siamese(6)% cvs commit

When Suan commits files, every one of those files must be up to date. If they aren't, CVS will refuse to commit the files. Suan can remedy this by updating them with cvs update.

Suppose Alexey wants to get fresh copies of all the files, including the proposal.html file Suan just added.

If he doesn't have a copy of the project checked out:

derby(1)% cd cs/736
derby(2)% setenv CVSROOT /u/c/o/colbster/CVS
derby(3)% cvs checkout cs736-p2

If he already has a checked out copy, and just wants fresh copies of any changes other users may have commited:

derby(4)% cd cs/736/cs736-p2
derby(5)% cvs update

It is usually a very good idea to run cvs update every time before you commit changes, as commiting an old copy of the tree may wipe out other users' changes.

Exporting A Version

When it comes time to turn in an image of the project to the professor, the cvs export command is very effective. cvs export works much like cvs checkout, except that CVS files are not created, only an image of the latest version (or whichever version you select).

First, a current image must be given a version number, or "tag" as CVS calls it.

Suppose Colby wishes to turn in the latest version of the project. First, he will commit any last changes.

alfred(1)% cvs commit
alfred(2)% cvs tag r97-10-12

This will tag all files with the version r97-10-12. Any version naming convention can be used, so long as it begins with a letter.

Now the repository contains the latest and greatest files, tagged with a version number, in this case, the date of the version. The repository is ready to emit an export of this version. Colby goes to his handin directory:

alfred(3)% cd /p/course/cs736-cao/handin/colbster

He can now export an image of the latest files:

alfred(4)% cvs export -r r97-10-12 cs736-p2

This will create the cs736-p2 directory tree, with all the files tagged with r97-10-12.

Things To Remember

You always have write access to your working files. You can cvs add filename or cvs remove filename at anytime, however other users won't be affected until you cvs commit.

A file must be up-to-date before you can cvs commit the file. So if Suan wants to cvs commit proposal.html, but Alexey does it first, then Suan must first do cvs update proposal.html. If there are any conflicts, Suan must resolve them, by editing the file, and fixing the conflicts (which appear as diff output within the file). Then he can do cvs commit proposal.html.

This document is intended to get you started with CVS, and is in no way complete. An excellent set of CVS docs live on the web at http://www.CVShome.org. Also, the CVS manual pages are very well written, and should provide information in much greater detail than this tutorial provides - try man cvs.

Happy Version Control!

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r4 < r3 < r2 < r1 | More topic actions
 
CSL Home
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback