Beginning CVS Lesson
By AdamShand (13 February 2003)
See Also: CvsNt, UsingWinCvs, UsingCvs, CvsLesson, CvsNtAdministration, CvsNtModified, CvsReference
What is Revision Control
- Typically used for code or document management.
- Generally only works on text files (binaries hard to diff).
- Stores all changes to files over time.
- Can group changes together with tags and branches.
- Allows release states to be marked.
Why is Revision Control Important
- Centralized management of code (gets code off peoples desktops).
- Protects against accidental mistakes.
- Protects against malicious activity.
- Allows geographically diverse groups to really collaborate.
- Only stores delta's between versions.
What is different about CVS
- Grew out of a collection of Unix tools and utilities.
- It's open source (eg. free).
Uses a concurrent developement model.
- Files are (typically) only stored on a server.
Files are stored as name.ext,v, actual files stored .
- It's cross platform.
CVS Commands and Terminology
- Module
- A directory hierarchy. A software project normally exists as a single module in the repository.
- Release
- The version of an entire product.
- Repository
- A collection of modules. Typically access is controlled on a per repository basis.
- Revision
- The version of a single file.
- Tag
- A symbolic name given to a set of files at a specific time of development.
- Add
- Add a file or directory to a module.
- Checkout
- Normally used to describe the first retrieval of an entire module from the repository.
- Commit
- Sending your modifications to the repository.
- Export
- Refers to extraction of an entire module from the repository, without any CVS administrative files: Exported modules will not be under CVS control.
- Import
- Normally refers to the process of creating a new module in the repository by sending an entire directory structure.
- Update
- Get other users' modifications from the repository. Updates the local copy only.
Miscellaneous Information
All directories which contain files under CVS control have a directory in them called CVS. This directory stores all the information about which repository, module, tag, branch etc. When you export a module (as opposed to checkout) the difference is the existance of these directories on the local files.
- CVS uses the term CVSROOT to mean three different things:
- There is an environment variable which you set to control the method, username, host and repository which you are using to login into the server.
- There is the CVSROOT directory in each repository. This directory contains all the configuration files (passwd, readers, writers, config, etc) for the module.
- There is also the cvsroot path, the path to a repository is often referred to as the cvsroot. For many CVS servers this is /cvsroot.
Sample Repository Structure
# ls /cvsroot sw/ tw/ ic/ qa/ se/ test/ # ls /cvsroot/test/ CVSROOT/ config/ sample/ # ls /cvsroot/test/CVSROOT/ Emptydir/ config editinfo,v modules,v rcsinfo,v verifymsg,v checkoutlist config,v history notify taginfo checkoutlist,v cvswrappers loginfo notify,v taginfo,v commitinfo cvswrappers,v loginfo,v passwd val-tags commitinfo,v editinfo modules rcsinfo verifymsg
Example WinCVS Session
Download and install WinCVS 1.2 (http://cvsgui.sf.net/).
- Configure basic settings "Admin - Preferences - General" set CVSROOT:
:pserver:adam@cvs.example.com:/cvsroot/test
- Go to "WinCVS" tab and set "HOME folder" to somewhere you want CVS stuff downloaded to.
- Go to "Admin - Login" and enter your password.
- To checkout a module go to "Create - Checkout module" and enter "sample" as the module name. Select the local folder where you want it downloaded to.
- Make sure everything suceeded (exit code 0).
- Go to the folder in WinCVS, browse around and right click on a file and choose "Graph Selection". To exit go to "Graph - Close".
- Try right clicking and choosing other options like diff or log.
- Browse to the directory in Explorer and find the CVS directory.
Now lets import new code:
- Go to "Create - Import module" and chose a smallish directory on your pc to import.
- Choose a name for your new module, don't worry about the vendor tags and put in a comment so people will know what it is.
- Follow the directions above to check out your new module.
- Find your new module, choose the file you want to edit and click the "Edit" button, this changes it from read-only to read-write.
- Edit the file, make some changes and save it. You'll see that the icon has now changed to red, this means that the copy you have is different from the copy on the server.
- Now lets commit the changes, find the file in WinCVS and right click and choose "Commit selection". If you changed more then one file you can also select entire directories to commit.
- Now checkout someone elses module and see if you can see their changes.
Congratulations, you now know the basics of CVS.
Further Reading
- CVS-NT Server Homepage
- CVS-NT Installation Guide
- CVS-NT FAQ
WinCvs Homepage
WinCvs Howto
TortoiseCvs Homepage