July 2002
On June 28, 2002, Eclipse 2.0 official version has been formally completed, which will be an important event in the history of Java development tools, and Eclipse starts to enter the mature phase. This article takes this opportunity to introduce some of the experiences and techniques of using the version control system CVS in Eclipse. First introduce why Eclipse wants to use CVS as its own version control system to give up Envy with Visual Age Java with a good reputation, then briefly tell the background of the CVS system and the installation and setting of the CVS server under the NT platform. Next, in response to Eclipse, the development process when the Team development using CVS is explained in detail, and the important operation methods for use in Eclipse.
background
After Visual Age Java, IBM launched a new generation of open source software development platform Eclipse, which creates its core product WebSphere family. For most personal developers, Eclipse provides a very attractive choice as a new Java integrated development environment, which has received more and more developers' attention and love.
The project version control is extremely important for team development. It is an indispensable tool for personal developers.
In Visual Age Java, due to Visual Age Java-specific project data storage mode - all related files exist in a binary, you can do direct built-in version control, this system is the famous Envy, it is in Visual Age Java has a very good reputation.
In Eclipse, the situation has changed. Envy stores the project data in a binary, that is, the so-called repository-based storage, and almost all other integrated development environments are filed based on files, and all related files of the project are directly stored on the hard disk. There are two ways of various ways, many users who have just contacted Visual Age Java are very uncomfortable, thinking that they do not see the files make them with the direct feelings, in turn also have Visual Age Java's faithful users to support and praise Envy. (However, the author believes that developers in Visual Age Java can at least almost completely don't have to spend their minds on the file path problem. This problem generally will always cost a lot of time and effort in the older.) In Eclipse, the file is finally used The storage method, which enhances transparency and interoperability, but the project management and source control before Visual Age Java must be achieved.
Eclipse's built-in version support
Eclipse itself has built-in version support, which is called Local History. The files edited in Eclipse will leave a record each time the replication can be recorded at any time, and the state is restored to a certain moment. Right-click on the file in the resource perspection or Java perspection (Java perspect), select Compare with, local history, will get the following screen, you can clearly see the differences in each version.
Figure 1: Built-in version support in Eclipse: Local History.
If needed, you can return to any previous version via Replace with, local history. Of course, the history of this version is limited, and can be set in the preference of Eclipse. In Preference-> Workbench-> Local History, you can set up to keep up to a few days of files, the number of versions of each file, and the size limit of historical files.
However, such version system only implements the most basic version of the version, if you want to mark a status as a version, add a comment (it is difficult to see the feature of each version from the save time in the local history, it is difficult Find an important key version), or want to put a directory or even the entire project version, Eclipse's built-in Local History is unobstructed. Good at Eclipse, based on open ideology, using the industry-standard version control system CVS, which not only greatly implements version control features, but also more easily for developers who have been familiar with CVS, more importantly, To provide a more flexible and open option for team development: The item's data can be stored in a CVS server. Different developers can even use different development tools as long as they support CVS. Perhaps we can understand why Eclipse gives up the ENVY system of Visual Age Java, which reflects the openness of Eclipse and good interoperability to other software.
Cvs
CVS is an abbreviation for Concurrent Versions System, which is based on mature SCCS (Source Code Control System) and RCS (Revision Control System), which is an open source project. It is currently the mainstream of version control system. software. A very common occasion of using CVS is open source project. Due to the distribution of developers of open source projects, most open source items are almost all CVS to manage source code, CVS standard and powerful visible.
CVS is stored in a central server using client / server system, code, and various versions. Every individual developer is developed to get a copy of their own copy from the server, based on this basis to avoid directly affecting the server. The data. Developers can submit their new code to the server at any time and maintain the latest state of the code to maintain the latest status of the code.
CVS is transparent to the network. Developers can use client software (almost all platforms have corresponding client software) at any time, anywhere through the network to get the latest code.
For Eclipse developers, Eclipse itself has built-in CVS support, and does not need to use other client software. You can use this powerful version control system as long as a CVS server is established.
CVS originated from the UNIX / Linux platform, there are many introductions about installation and use under the UNIX / Linux platform. This is no longer repeated. If the reader needs to establish a CVS server under the UNIX / Linux platform, you can refer to the relevant resources of this article.
There is also an implementation of CVS on the Windows platform - CVSNT, CVSNT installation has certain difficulties, here we do a brief introduction. CVSNT installation
First, go to CVSNT's home page http://www.cvsnt.org Download the latest version, currently CVSNT 1.11.1.3 (Build 57F).
The installation of CVSNT has some precautions. The reader is required to install as much as possible in the following steps, which is primarily for Windows 2000. If the reader has problems during the installation process, you can refer to the list of installation techniques or mail for CVSNT in the resource of this article.
CVSNT can be installed on a Windows NT4 server or workstation SP6, Windows 2000 server, or a professional version, Windows XP Professional. Log in with an administrator account, first modify the environment variable. Directly perform the installer, it is very likely that the error cannot create a path variable, and we first modify the environment variable and set the path. Suppose we have to install the CVSNT to the D: / App / CVSNT directory (preferably on the NTFS partition with CVSNT, try not to use a directory name or file name containing spaces, although CVSNT has tristed to support the space Directory name and file name, but there may still be a problem), turn on the control panel, system properties, advanced, environment variables, system variables, add D: / App / CVSNT and save the settings. Next, you can perform the installer, modify the installation directory, and complete the installation step by step. Start the CVSNT Configuration Program Configure Server from the program group of the start menu. At this time, you should see that the server has not yet runned (CVSNT is running as system service), if it has been run, first stop it first. Select the second tab Repository, first check the options for the Repositories Prefix (Database path prefix). There is only one database path prefix in CVSNT, and under the same prefix, there can be multiple databases. Correspondingly, all databases are located below the directory of the database path prefix. Here we assume that the database is stored under E: / WORK / CVSREPO, click the ingredient button to select E: / WORK / CVSREPO as the database path prefix. Click on the Add button below to add a database root, you can have multiple. For example, we will / work as the storage root of our work items. Note that the system automatically uses the set E: / Work / CVSREPO as the path prefix. Select the third tab Advanced to hook all options, including Use local users instead of domain. Set the temporary directory, assume that it is E: / WORK / CVSTEMP. Note To ensure the security settings of the temporary directory (right click on directory properties, sharing, permissions) to all accounts to fully control the permissions, including the System account. Also, the temporary directory must not be set anywhere, such as C: / WinNT / TEMP or C: / Documents and Settings, because these places are limited to users' access. Click to apply to save the settings, this is quite important. Now you can return to the first tab, click the Start button, the service should start running normally. If there is a problem, you can open a command line window, enter the path command to check if the path has been set correctly, may need to restart to make the settings take effect. Open a command line window, enter the following command, use your actual computer name and username to replace the content within the spare bracket, pay attention to NT Server, you can't use localhost as your computer name, you must use the actual computer name: set cvsroot =: Ntserver: < Computer Name>: / Work This command is set to set the cvsroot environment variable, set / work as the current CVS database root. This mode is compared to the server in the local situation using NTServer mode. It requires the same user account in the local area network or all machines in the domain, and the client uses Windows NT, Windows 2000 or Windows XP. The PServer mode is default unless the 2401 port is turned off, the following our Eclipse is using the PServer mode.
CVS Passwd -a
As mentioned earlier, the data of CVS is stored in the database of the server. To support Concurrent, CVS uses a branch model to ensure relatively independent of different developers, but also highly integrated. Branch can be seen as a work area shared by a team, in the CVS database, there is a special branch called HEAD, representing the main workflow.
Developers can submit (commit) their own work and keep synchronization with the latest modifications to others through updates. Submitting is submitted to the database, called output, and updates are modifications to others, called input (incoming). Before you submit, you should be updated first to keep synchronization with the latest state.
Therefore, in Eclipse, the CVS is used to develop, and the ideal development process should be such (the specific method of operation):
Figure 2: Team development process
Start with the latest state. Before you start your work, ensure that all resources are consistent with the latest branching state. For new projects starting from scratch, first connect to the server to set the resource files. For items already recorded in the server database, you must first update to ensure the latest resource status. If the local work does not need to be particularly saved, you can directly put the latest version of the database at Check Out as Project, or Replace with, Latest from repository. Conduct local work and save modifications. Synchronize. When preparing for your submission, you must synchronize with the server database.
First, you should update (update), check all incoming changes, enter to the local, see if you will affect your work, whether you will cause conflicts, destroy integrity, etc. After checking the updated, you can confirm that your work and the latest BRANCH content are consistent, you can submit (commit) your own modification, labeled appropriate comments.
The main operations used in this development process are described below.
For a new project, the first thing you need is to set Eclipse to connect to the CVS server. The first connection will be synchronized with the server (Synchronize).
First, right-click on the project in Eclipse's resource view (the Java perspection), select Team, Share Project, the prompt window will appear, and choose to use the known CVS database location or the new database location. For the first time to connect the CVS server, you will need to first define the server parameters and paths, user names, passwords, and so on. These parameters will be saved, and if you need to reconnect, you can use known CVS databases directly. Here we choose to create a new database location and enter the next input screen.
The host name (Host) here can enter localhost (which is not allowed in Windows NT 4) because our CVS server is in this unit.
Next, enter / Work, set our project data to store under this database root path.
Then enter the username and password.
Connection Type Select PServer, the port is default no change. Of course, if you modify the port used by the CVS server, you must be consistent here.
Figure 3: Setting using a CVS system in Eclipse
Next, you can click Finish to complete the settings. If you click Next, you can continue to define if you use different names with the project name as a module name in CVS. The default is the same name.
Now we have completed the connection between the project and the CVS server, and the project has been synchronized with the CVS server.
But this does not mean that CVS has begun to record version information. Because there may be considerable part of the resource file in a project that is not suitable for storage to record version information in the database, such as temporary files generated by the editor, compiling the generated .class file, or binaries generated by some compilerics, etc. Therefore, Eclipse does not automatically store all files into the database, requiring developers manually specifying those files into the database, that is, add version control add to version control. For a single file specified, you can use the right click at any time in the resource perspection or a file in the Java perspection (Java perspect), select Team, Add to Version Control. If you need to store the entire project or specify multiple files, you want to use a synchronization (Synchronize) view.
Note that the project is completed and synchronized with the CVS server connection, and a Synchronize window appears in the lower right corner of the Eclipse's lower right corner. The following status bar also shows the status information of this synchronization. Double-click the title bar of the SYNCHRONIZE window to maximize it, we can see that the upper half of the window lists all resources and files that have not specified join the database. Here we can select multiple files at the same time, even select the entire project, use the right click, select Team, Add to Version Control, you can add multiple files or entire project to the database, and start to record its version information.
We can see that the Outgoing mode is indicated on the synchronization view at this time. Synchronize view has Incoming mode and Outgoing mode, corresponding to submitting (Commit) and Update operations, indicating that the current modification comes from the local or from the server. Of course, the view can also display changes in incoming and Outgoing direction at the same time. When there is a change, the comparison window in the lower half can display differences and variations between different versions. Further, the conflict caused by different modifications of the same file can be eliminated by the merge (MERGE) operation on the toolbar. After that, when the modification of the file or item is completed, you need to confirm the modification, store the latest status to the database, you need to perform submission (Commit). Similarly, we can use the right-click on the resource perspective or Java view (Java perspective) to select Team, Commit; or submit multiple files and even the entire project at the same time. Note that each submission will be prompted to enter a comment, which is important as a description and prompt of each state.
When we need to compare or replace different versions of the file or item, you can use the right click on the resource persftive or Java perspection, select Team, Compare with or Team, Replace with to complete . A comparison editor will open when compared, which is well shown in different versions, and similar to Local History.
If you want to know the content of the CVS database, you can use the CVS database to browse the view (CVS Repository Exploring Perspective). We can click on the Open perspect button in the top left of the Eclipse to add this view to the view browsing bar on the left. As mentioned earlier, Head represents the mainstream content in the CVS database. Expand Versions and you can see past versions. In addition, there is a history of the database in the lower right corner indicate the relevant information for each modification.
If you need to export a version, you should use the Check Out operation. Right-click on a version to select Check Out as Project, which will export this version as the same name, so that you can override the existing state, or select the Check Out dialog to export as other items.
Figure 4: CVS Database Browsing View
For more detailed CVS usage methods and techniques, you can refer to the help in Eclipse.