CVS is a version control system. It is used to record the
history of your source files.
Bugs can creep in when software is modified, and may not be detected until a long
time after the modification is made. With CVS, you can retrieve old versions to
find which change caused the bug.
CVS can also help when a project is being worked on by multiple people, where
overwriting each others changes is easy to do. CVS solves this problem by
having each developer work in his/her own directory and then instructing CVS to
merge the work when each developer is done.
CVS Documents https://www.cvshome.org/docs/
CVS Manual https://www.cvshome.org/docs/manual/
Online
Introduction to CVS: https://www.cvshome.org/docs/blandy.html
+-------------+
Branch 1.2.2.3.2 -> ! 1.2.2.3.2.1 !
/ +-------------+
/
/
+---------+ +---------+ +---------+
Branch 1.2.2 -> _! 1.2.2.1 !----! 1.2.2.2 !----! 1.2.2.3 !
/ +---------+ +---------+ +---------+
/
/
+-----+ +-----+ +-----+ +-----+ +-----+
! 1.1 !----! 1.2 !----! 1.3 !----! 1.4 !----! 1.5 ! <- The main trunk
+-----+ +-----+ +-----+ +-----+ +-----+
!
!
! +---------+ +---------+ +---------+
Branch 1.2.4 -> +---! 1.2.4.1 !----! 1.2.4.2 !----! 1.2.4.3 !
+---------+ +---------+ +---------+
Each group has its own repository: /classes/cs3141/project/group#/src
csh
$setenv CVSROOT /classes/cs3141/project/group#/src
bsh
$CVSROOT=/classes/cs3141/project/group#/src
$export CVSROOT
$cvs init
‘cvs init’ creates a dir named CVSROOT under $CVSROOT. Do not remove the diretory CVSROOT
If you want to put some existing project files under CVS control, you can use the import function.
To import a project, run the command below,
$cvs import –m “log msg” projnam vendortag releasetag
-m: the first log file for the entire project
projnam : the directory name that will be created in CVS repository
Example:
$cd myproj
$cvs import –m “initial import into CVS” myproj jrandom start
Every file (include files under subdirs) will be checked into repository. Cleanup files under myproj first!
If you just want to create a new project, first create a empty directory and then perform the above import.
Example:
$mkdir myproj
$cd myproj
$cvs import –m “initial import into CVS” myproj jrandom start
$cd {desired_working_directory}
$cvs checkout {projectname}
A directory named {desired_working_directory}/{projectname} will be created, all the latest version of source code will be extracted and put under the dir.
$cd {projectname}
$vi
$make
Compile your code … Debug it … Test it …
$cvs update
$cvs commit {filename}
You can specify the filename to commit only one file, instead of all files for that project.
$ cvs update
Verify and test the merged files with other people’s change.
$cvs log {filename}
This command shows all the comments associated with each commit command.
$cvs diff –c –r 1.6 –r 1.7 {filename}
This command shows all the content change between two versions.
create the new file
$cvs add {filename}
$cvs commit {filename}
delete the file
$cvs rm {filename}
$cvs commit {filename}
Why the change was made? Not just what was the change.
More than one people made change in some spot.
Very rare.
$cvs status {filename}
Up-to-date
The file is identical with the latest revision in the repository.
Locally Modified
You have edited the file, and not yet committed your changes.
Needing Patch
Someone else has committed a newer revision to the repository.
Needs Merge
Someone else has committed a newer revision to the repository, and you have also made modifications to the file.
The permission can be
controlled by file permission settings in the repository.
Initialize the
repository and import your files as in step 1 and step 2.
Open a new project with CVS wizard, or open
project, then click Window -> Open Perspective-> CVS repository exploring
Add a new repository using
Host:
wopr.csl.mtu.edu or Joshua.csl.mtu.edu
Repository
path: the full path of the directory where repository was created. ( basically the value of CVSROOT env
as in step1)
Authentication:
the lab account and password
Connection:
extssh
https://www.cvshome.org/docs/manual/
keywords:
$Author$
$Date$
$ID$
$Revision$
$Source$
$Log$
Example:
The header of server.java was:
// $Source$
// $Date$
// $Revision$
// $Id$
// $Author$
// $Log$
after importing into CVS and being checked out, the keywords were replaced with values
// $Source: /home/csdept/ruihong/CVSROOT/poker/server.java,v $
// $Date: 2005/01/27 03:08:00 $
// $Revision: 1.1.1.1 $
// $Id: server.java,v 1.1.1.1 2005/01/27 03:08:00 ruihong Exp $
// $Author: ruihong $
// $Log: server.java,v $
// Revision 1.1.1.1 2005/01/27 03:08:00 ruihong
// initial import into CVS
After making some change and a commit,
[ruihong@icu20 ~/poker]$ more server.java
// $Source: /home/csdept/ruihong/CVSROOT/poker/server.java,v $
// $Date: 2005/01/27 03:12:04 $
// $Revision: 1.2 $
// $Id: server.java,v 1.2 2005/01/27 03:12:04 ruihong Exp $
// $Author: ruihong $
// $Log: server.java,v $
// Revision 1.2 2005/01/27 03:12:04 ruihong
// This is just a test to see header change.
//
// Revision 1.1.1.1 2005/01/27 03:08:00 ruihong
// initial import into CVS
//
This is a test for checking new logs appended in the header
Exercise
The goal of this exercise is to get familiar with CVS.
1. Create a new directory under your home directory and check your existing
project source code into the new repository.
2. Checkout the project from CVS into a new working directory.
3. (Optional) delete the
original directory
4. Under working directory, modify some files. Commit the change.
5. Add some keywords in the header of the files. Commit the change.
6. Create a new file say README in the working dir, check it into CVS.
7. Simulate the situation that multiple developer working on the same source
code.
Checkout
the project from CVS to a second working directory.
Change a file in
the first dir and commit it .
Change
the same file in the second dir and commit it.
Do you see the merge
of both changes after you commit it? Try to make it work.
8. run "cvs log"
9. tagging ( tag files for releases)
10. branching ( make a new branch out of the trunk for
maintenance)