CVS--Concurrent Versions System v1.12.12.1 with Eclipse 3.1.1

 

Introduction

 

If you are a Java programmer, and want to simply use CVS with Eclipse under Linux, you can refer to this document to install, configure, and use CVS.

 

Prerequisites

Install CVS

 

1.     Log in as root administrative

 

2.     Installing CVS

 

$ yum install cvs

 

3.     Create a CVS system account

$ useradd cvs
$ sucvs

$ mkdir newproject

          ¡°newproject¡± is a new folder which will be used for a repository, and it is a sub folder of ¡°/home/cvs.¡±

          You can also use ¡°/home/cvs¡±, but creating a new folder for each project is recommended.

4.     Edit /etc/services

$ cvspserver 2401/tcp # CVS client/server operations
$ cvspserver 2401/udp # CVS client/server operations

 

          Edit /etc/services and save the above.

 

5.     Create /etc/xinetd.d/cvspserver

service cvspserver
{
    disable = no
    flags = REUSE
    socket_type = stream
    wait = no
    user = cvs
    server = /usr/bin/cvs
    server_args = -f --allow-root=/home/cvs/newproject pserver
    log_on_failure += USERID
}

 

          Register for CVS as a xinetd service.

          Add the path of new project like --allow-root=/home/cvs/newproject between "-f" and "pserver."

          Edit the name of system    user like ¡°user = cvs.¡±

1.     Restart xinetd

 

service xinetd restart

 

 

2.     Initiate CVS repository

 

$ sucvs

$ cvs -d /home/cvs/newproject init

 

          Initiate CVS repository to store source files.

 

3.     Add a user for CVS

          - Create cvsuser

$ useradd cvsuser

         

          - To make a script for creating a cryptopasswd, edit /usr/local/bin/cryptpasswd as following

#!/usr/bin/env perl
srand(time());
$randletter = "(int (rand (26)) + (int(rand(1) + .5)% 2?65:97))";
$salt = sprintf("%c%c",eval$randletter,eval$randletter);
$plaintext =shift;
$crypttext = crypt ($plaintext,$salt);
print "${crypttext}\n";

         

          - Change the mode of cryptpasswd file to allow anyone to execute

$chmod a+x /usr/local/bin/cryptpasswd

 

          - Create a user, change the user¡¯s password, and register the user for a repository

$useradd cvsuser

$su - cvs
$cryptpasswd password
$vi /home/cvs/newproject/CVSROOT/passwd

$ cvsuser:pVjR8rECLd1L:cvs

         

          Now, ¡®cvsuser¡¯ can access ¡®newproject¡¯ repository via cvs account.

4.     Test repository

 

$cvs –d :pserver:cvsuser@IP of cvs reporitory:/home/cvs login

 

 

 

Use Eclipse as a CVS Client

 

Create Project

 

1.     Create a project in Eclipse to register a host project in the CVS repository.

 



2.     Register this project to CVS repository

Select the project and click the right button, and Team > Share Project..>

Enter repository location information.

 

For host, you can enter your host¡¯s IP address. For Repository path, you can enter the path you defined at 7. Initiate CVS repository

in the above section.

 


 

Enter module name you want to use.

 


 

Next > Select resources to be shared by pushing ¡°Share Resource¡± and Finish.

 


         

   If ¡°Commit files¡± popup is open, then you can enter a comment.

 


 

     Finish.

 

      You can see the mark of test project is changed from a folder icon to a repository icon.

 

 

Share Project

 

1.     Now, we can share the project on a clinet machine.

In a client, create a new project by checking out projects from CVS.

File > New > Project..

 

                        

         

          Next  

 

         

     

          Select Module you want to use.

 

         

   

      Finish

      You can see a new project.

 

         

 

 

 

Update files

 

1.     Update a file in the CVS repository

Update HelloWorld.java with a new message. You can see the ¡°>¡± mark in the left of the file name and the folder name which the file contains.

 

           

 

2.     Update the HelloWorld.java in the repository.

Select the file and click the right button, and Team > Commit..>

    

                                                

 

     Comment for commit

 

 

       Finish

       You can see the ¡°<¡± is removed.

 

                  

3.     Now, we can use this updated file in the other client.

        Project > Team > Synchronize with Repository

* You'd better not allow to open another perspective for synchronizing view.

You can see the HelloWorld.java is updated to version 1.2 in the synchronize view.

 

         

 

Select the changed file, and click the right mouse button > Update

Now, HelloWorld.java is changed to version 1.2 in left Package Explorer.

 

 

 

 

4.     Conflicting files

 

When multiple developers work on a software project, it can commonly happen that several people try to edit the same file simultaneously. When the first person that commits his changes, CVS does not provide any automatic way of knowing that another has started to edit it. Others will get an error message, when they try to commit the file. They must then use Update commands to bring their working copy up to date with the repository revision. Even, CVS displays a popup message like the below, this process is not automatic. Therefore, developers should pay attention to this case.[1]

 

 

 

Reference

[1] http://ximbiot.com/cvs/wiki/index.php?title=CVS--Concurrent_Versions_System_v1.12.12.1:_Multiple_developers