Anytime a developer uses CVS, the location of the repository, or CVSROOT, must be defined. A CVSROOT has this format:
:protocol:userid@host:location
The CVSROOT can be set for all CVS commands by setting it as an environment variable or individually for each cvs command using the -d option. This is how to set the CVSROOT to a local CVS repository:
set CVSROOT=:pserver:bonhamcm@localhost:C:\CVSROOT (Windows)
or
export CVSROOT=:pserver:bonhamcm@localhost:C:\CVSROOT (UNIX
bash shell)
Here's how to set the CVSROOT for an individual CVS command:
C:\>cvs -d :pserver:bonhamcm@localhost:C:\CVSROOT login
cvs [global options] command [command options] [command parameters]
Here are a few of the most commonly used commands:
C:\>cvs -d :pserver:bonhamcm@localhost:C:\CVSROOT login
Logging in to :pserver:bonhamcm@localhost:2401C:\CVSROOT
CVS password: ***
C:\>mkdir indyjug
C:\>cd indyjug
C:\INDYJUG>cvs import -m"Initial import" indyjug indyjug start
No conflicts created by this import
Here is the format for the import command:
cvs import [-m"comment"] repository-directory vendor-tag release-tag
If the comment parameter is not specified, CVS will prompt the user for one. The repository-directory is the location where the module will reside in the repository, indyjug in this case. The vendor-tag and release-tag parameters are required but are not currently used in CVS.
Once the module has been added, you need to get out and delete the working directory, and then check it out in order to use it.
C:\INDYJUG>cd ..
C:\>rmdir indyjug
C:\>cvs checkout indyjug
cvs server: Updating indyjug
The checkout command will create a directory with the same name as the module underneath the current directory. All the subdirectories and files in the module will be recursively copied to the client machine in a working directory so the developer can work on the code.
C:\INDYJUG>cvs add Hello.java
cvs server: scheduling file `Hello.java' for addition
cvs server: use 'cvs commit' to add this file permanently
C:\INDYJUG>cvs commit -m"Initial import" Hello.java
RCS file: C:/CVSROOT/indyjug/Hello.java,v
done
Checking in Hello.java;
C:/CVSROOT/indyjug/Hello.java,v <-- Hello.java
initial revision: 1.1
done
C:\INDYJUG>cvs diff Hello.java
Index: Hello.java
===================================================================
RCS file: C:/CVSROOT/indyjug/Hello.java,v
retrieving revision 1.1
diff -r1.1 Hello.java
2c2
< private static final String HELLO = "Helo IndyJUG!";
---
> private static final String HELLO = "Hello IndyJUG!";
The diff command will show each line that has changed from the latest revision in the repository. Differences between individual revisions viewed like this:
C:\INDYJUG>cvs diff -r 1.1 -r 1.3 Hello.java
Index: Hello.java
===================================================================
RCS file: C:/CVSROOT/indyjug/Hello.java,v
retrieving revision 1.1
retrieving revision 1.3
diff -r1.1 -r1.3
0a1,4
> /*
> * $Id: Hello.java,v 1.3 2001/11/28 15:23:39 bonhamcm Exp
$
> */
>
2c6
< private static final String HELLO = "Helo IndyJUG!";
---
> private static final String HELLO = "Hello IndyJUG!";
C:\INDYJUG>cvs log Hello.java
RCS file: C:/CVSROOT/indyjug/Hello.java,v
Working file: Hello.java
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions:
3
description:
----------------------------
revision 1.3
date: 2001/11/28 15:23:39; author: bonhamcm; state:
Exp; lines: +4 -0
Added $Id$ tag
----------------------------
revision 1.2
date: 2001/11/28 15:21:20; author: bonhamcm; state:
Exp; lines: +1 -1
Fixed hello string
----------------------------
revision 1.1
date: 2001/11/28 15:19:33; author: bonhamcm; state:
Exp;
Initial import
=============================================================================
Working revision: 1.3
Repository revision: 1.3 C:/CVSROOT/indyjug/Hello.java,v
Sticky Tag:
(none)
Sticky Date:
(none)
Sticky Options: (none)