Importing Projects into CVS

by Jeff Hunter, Sr. Database Administrator


  1. Overview
  2. The Initial Project Directory Structure
  3. Importing the Project
After successfully creating a CVS repository, it is time to start creating (importing) projects into the repository. Under CVS, a project is simply a collection of related files under a single directory.

This article describes how to import new projects into a CVS repository. For the purpose of this example, the following assumptions will be made:

Creating the Initial Project Directory Structure
Now let's create the initial project directory structure for our project (ProjectX). Put some thought initially into how you want the directory structure before importing into CVS. If, for example, you decide to move a set of files after they have been stored in CVS, CVS will now consider two versions of each file: the original set of files in their original location, and the second set of files in their new location. The history of those files are then split into two parts.

Once we create and import our initial project into the CVS respository, the initial version can (and should) be removed. You would not typically want to use this directory for your workarea (also known as your sandbox) so there is no reason to retain it.

Once we have the initial directory structure complete, we will need to change into the root directory of the project. Then, from within that directory, you can import the project using the following syntax of the cvs command:

cvs [ -d repository_path_name ] import name_of_project vendor_tag release_tag
Let's take some time to discuss the above parameters. If the CVS repository is on the local machine, then simply use the full path of the repository directory for the repository_path_name. That will be the case in this example. If the CVS repository is on a remote machine, see "
Logging into CVS / Setting CVSROOT" for detailed instructions on setting the repository location. For the name of the project, we will be setting the parameter name_of_project to ProjectX. As for the vendor_tag and release_tag, I like to set vendor_tag = INITIAL and release_tag = start. These are the conventions used in JDeveloper from Oracle.

Importing the Project
Now finally, let's create our initial directory structure for ProjectX and import it into the repository:
% cd /tmp
% mkdir ProjectX
% touch ProjectX/
% touch ProjectX/
% touch ProjectX/
% cd ProjectX
% cvs import ProjectX INITIAL start
After the running the cvs ... import ... (above), CVS will put you into an editor windows (probably vi). This is where you would enter any message to remind you of what the project is about.
This is the initial import of ProjectX. If this were a real project, I
would consider putting the project specification document here.
CVS: ----------------------------------------------------------------------
CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
CVS: ----------------------------------------------------------------------
After exiting from the editor, CVS will complete the import process as show below:
N ProjectX/
N ProjectX/
N ProjectX/

No conflicts created by this import
After importing a project, it is always a good idea to backup the repository (as well as your original directory structure for the project). After importing the project and backuping up the repository, you should remove the original directory structure that we imported since you cannot use it as a sandbox.
% cd
% rm -rf /tmp/ProjectX
As a final step, you should verify that the project is in the CVS repository by checking it out in your work area (or sandbox area):
% cd ~
% mkdir myWorkArea
% cd myWorkArea
% cvs co ProjectX
cvs checkout: Updating ProjectX
U ProjectX/
U ProjectX/
U ProjectX/
You can also perform a directory listing on the CVS repository:
% ls -l /var/lib/cvsroot
total 4
drwxrwsr-x   3 cvs      cvsdev      1024 Jan 23 19:30 CVSROOT/
drwxrwsr-x   2 oracle   cvsdev       512 Jan 24 19:29 ProjectX/

% ls -l /var/lib/cvsroot/ProjectX
total 6
-r--r--r--   1 oracle   cvsdev       505 Jan 24 19:22,v
-r--r--r--   1 oracle   cvsdev       505 Jan 24 19:22,v
-r--r--r--   1 oracle   cvsdev       505 Jan 24 19:22,v

Last modified on: Saturday, 18-Sep-2010 18:16:09 EDT
Page Count: 82497