Use of CVs in eclipse

Source: Internet
Author: User
Tags version control system
use of CVs in Eclipse 5.1 CVS introduction

CVS is the abbreviation for Concurrent versions System (concurrent version systems). It is an open source project, is the most popular version control system, the majority of open source projects are now used to do version management. If you are still accustomed to using Microsoft's VSS for versioning of Java projects, then it is recommended that you switch to CVS when you use Eclipse.

CVS employs the client/server system, the various versions of the code and documents are stored on the server side, the developer first from the server to obtain a copy to the local, and then on this basis for development. Developers can submit new code to the server at any time, and of course they can get the latest code through the update operation, keeping up with the other developers.

The eclipse itself has a built-in CVS client that can use this powerful version control system just to build a CVS server. Although CVS is powerful, general projects typically use only 20% of their functionality, so just understand the most common operations, and this chapter will introduce CVS in a way that is intended for actual project use. 5.2 CVs server-side installation and configuration

CVS originated in the Unix/linux platform, the Unix/linux platform for the installation of the use of CVS server-side articles, a plethora of online, this section will not repeat. CVS server in the Windows platform version: CVSNT, it is difficult to install, this section will focus on the installation of cvsnt.

First go to cvsnt homepage http://www.cvsnt.com/downloads/to download it, download the method refer to the video demo of the book CD. The current version is Cvsnt 2.0.58d, which can be installed on Windows nt/2000/xp/2003.

(1) Run Setup without changing any of its default settings, and then click the Next button continuously to complete the installation. CVSNT is installed by default in the "C:/Program files/cvsnt" directory.

(2) through Windows select the "start → All programs →cvsnt" option to open the CVSNT Settings Panel "Service Control Panel", as shown in Figure 5.1, the above two services have been started.

% Note: If you are prompted not to find Rundll32.exe, click the Browse button, point to C:/windows/system32/rundll32.exe, and run it.

(3) Click the Repositories tab in Figure 5.1, and then click the Add button to create a directory "C:/cvsfile" for the version file, as shown in Figure 5.2, and then click the OK button to answer "Yes" in the two windows that pop up.

% Note: It is recommended that you do not use automatically generated "/cvsfile" in the name bar, but instead write the absolute path "c:/cvsfile", otherwise it may not be used normally after cvsnt installation.

Figure 5.1 Service Control Panel interface Figure 5.2 Creating a directory for storing version files

(4) Go to the "Compatibility" tab and select all 3 options, as shown in Figure 5.3.

% Note: This step is important, otherwise the CVS 2.0.58d will not work properly under Eclipse 3.0.1, if you use the Eclipse 3.1M4 version, this step setting can be skipped.

Figure 5.3 Compatibility tab

(5) CVS client to connect to the server, also need to assign a user name on the server side, and user name requirements must be Windows login user. This book logs on to Windows XP with a username of Giles and a blank password. Enter the Windows command Line window, as shown in Figure 5.4, go to c:/program files/cvsnt directory, enter command cvs-d C:/cvsfile passwd-a Giles, press ENTER to enter Giles login password on CVS (this book set Password is 123456, this password can be different from XP.

% Note: After installing the CVSNT, you can also create a new user via "user account" in the control Panel, when the user automatically becomes a CVS user with the same password.

At this point, the CVS server part of the setup is complete, the client can already use Giles for the account to log on to CVS.

Figure 5.4 Command Line window

(6) Other

Porting or restoring CVS is involved if you want to migrate CVS files to another computer, or if the original CVS server has a computer that has the operating system installed. As an example of the Cvsfile directory of the book's CD-ROM (CVS backup in later chapters), the reader simply copies the directory to the local computer (which can be renamed), and then registers it with the action shown in Figure 5.2. So, backing up the files on CVS requires just one copy of the Cvsfile directory, very simple.

If the reader is more restrictive about permissions, you need to set the permissions of the CVS user, which is related to the operating system's permissions (users are the operating system's users), that is, the reader needs to set permissions for the Windows file directory.  5.3 The configuration of the CVS client 5.3.1 Configure Eclipse's clients to connect to the CVS server

Open the CVS repository research perspective in Eclipse, and then right-click in the CVS repository view on the left, and select the new → repository location option in the right-click menu. Enter CVS information in the pop-up window, as shown in Figure 5.5, and click the Finish button when you are finished.

Figure 5.5 Adding a CVS repository

% Note:

(1) The repository path is the absolute path on the CVS server, the value of the Name text box in Figure 5.2.

(2) The password is the 123456 that is set above with the CVS command line. However, if you create a user through the user account in Control Panel, the password is the user's Windows logon password. 5.3.2 The project to a CVS server

The steps for submitting the project to a CVS server are as follows:

(1) Go to Eclipse's resource perspective. Right-click the project name MyProject and select the group → Shared items option, as shown in Figure 5.6. In the Shared Items window that pops up, accept the default settings and click the Next button directly.

Figure 5.6 The Shared Items window

(2) as shown in Figure 5.7, the window prompts for the module name, accepts the default option, and clicks the Next button.

Figure 5.7 Shared Items-Input module name

(3) as shown in Figure 5.8, select the project resource (that is, the file) to be submitted to CVS in the window, do not have to make any settings (default is to submit all files of the project), and click the Finish button directly.

Figure 5.8 Shared projects-project resources

(4) as shown in Figure 5.9, a continuous pop-up two windows, all click the "Yes" button. A pop-up window is also required to enter a submit comment, write some explanatory text (or it can be empty), click OK, and Eclipse begins submitting the project file to the CVS server.

Figure 5.9 The Resource Submission dialog box 5.3.3 The project on the CVS server into Eclipse

If a new co-worker joins the project development team, then he needs to import the artifacts from the CVS server into his own eclipse. To facilitate impersonation, install an eclipse, as long as the installation directory is different, two eclipse runs at the same time there will be no conflict. The steps to import a project from a CVS server into eclipse are as follows:

(1) Select the "file → import" option in the main menu, and pop up the window shown in Figure 5.10.

Figure 5.10 The Import window

(2) Select Check out items from CVS and click Next. Pop up a location window that sets the repository, accept the default option, and click the Next button directly to pop up the window shown in Figure 5.11.

Figure 5.11 Completing the module name on CVS

(3) In the Module Name text box input MyProject, click the "Next" button, pop-up as shown in Figure 5.12 window. MyProject This name is not the project name, but the module name that the project shares to CVS (see Figure 5.7 for the module name), except that the CVS module name is usually taken as the project name.

Figure 5.12 "Check out as" window

(4) Enter MyProject in the Project Name text box (optionally named). Eclipse will build a project with this name and export the CVS file to this project. Click the Finish button directly in the window to start importing the latest files from the CVS server into the local machine. 5.4 Method of file submission and update 5.4.1 The differences between CVS and VSS

For readers who have used Microsoft VSS, it is important to understand the differences between the CVS file operations:

(1) VSS must check out (checkout) file to modify this file. At this point, the file will be locked, other people can no longer modify (readable), you must wait for the file to be the last modifier check in (submit), that is, VSS same file only allow one person to modify.

(2) CVS uses a completely different mechanism, and many people can modify the same file at the same time. The file is not locked like VSS, so there is no action to check out (checkout) before the file is modified, and the most basic operation of CVS is "submitting files to CVS" and "Updating files from CVs to native". Of course in CVS if more than one person modifies a file at the same time, the code is prompted to conflict when submitted, and a window is provided to merge the changes, but such a merge modification is cumbersome, so you should avoid as many people as possible to modify one file at the same time. 5.4 . 2 submission and updating of documents

1. Submit the modified file to CVS

Add an output statement "System.out.println" ("First modified") in the Helloworld.java, and save. Right-click the Helloworld.java file in the Navigator view on the right side of the window and select the group → submit option in the pop-up menu, as shown in Figure 5.13.

Figure 5.13 Submission Interface

2. Update files from CVS to native

Delete the statement in Helloworld.java "SYSTEM.OUT.PRINTLN (" first modification ");" Then save, there are two ways to update the latest code on the CVS server to Local:

(1) Right-click the Helloworld.java file and select the "Replace with →head" option in the pop-up menu.

(2) Right-click the Helloworld.java file, select the "group → sync with repository" option in the pop-up menu, and in the Sync interface that pops up, click the copy current changes from right to left button, and then save.

Figure 5.14 Resource Pool Synchronization interface

The reader may ask: "Right-click the Helloworld.java file and choose ' group → update ' This update method, why not?" ”

This update is to update the latest version of CVS to the local computer and use this method when the native files are not modified. If you make changes to HelloWorld, the reverse is the old content on CVs, and then using this update method will have no effect on the local Helloworld.java file. 5.4.3 Resolve file submission conflicts

In the development of multiple-person projects, a submission conflict arises as a result of the simultaneous modification of a file, and this section explains how to resolve the conflict.

When the project was checked out, another eclipse was installed, equivalent to one more developer, the original called Giles, and the new addition was called Tom. The version of Helloworld.java on Giles and Tom's computer is 1.2. Then Giles adds a statement to the file "System.out.println (" Giles for the 1th time); "And Tom also made a similar change in the file, as shown in Figure 5.15.

Figure 5.15 Modification of code by two developers

Giles first submitted the Helloworld.java file, when the version became

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.