Use version control system CVS in Eclipse
2003-12-19
Author: Feng Wei
table of Contents
Foreword .. 3
Background. 3
Eclipse's built-in version support .. 4
CVS. 5
Basic concept .. 5
CVSNT installation .. 7
Use the CVS system in Eclipse.. 9
Basic workflow .. 9
Set the location of the repository .. 10
Sharing items ... 12
Enable CVS resource modification .. 17
Export item .. 18
Synchronize with CVS repository .. 20
Update .. 20
Submit .. 24
Merge from branch .. 24
Related resources .. 25
Foreword
The project version control is extremely important for team development. It is an indispensable tool for personal developers.
This article describes how to use the version control system CVS in Eclipse. First, we will briefly discuss the idea of team code development, then briefly tell the background of the CVS system and the installation and setting of the CVS server under the Windows 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
Most of today's applications are developed by multiplayers. Even if only a small project of several developers, changes to the source code are needed to strictly control. This is the task of the source code management software. Source code version control software must support two core functions:
Provides a method to coordinate changes to source code and can integrate these changes
History of the team's submission
When team members have completed new work, they will share their work by submitting these changes to the repository (Repository). Similarly, when they want to get the latest available work results, they can update their local workspaces (Workbench) according to the changes in the repository. This means that the content of the resource library will often change team members to update their work space according to the resource library because of team members to submit new work results. Confident they are the latest.
Maintaining history is also important, so you can compare the current work with previous versions, if necessary, you can reply to the previous version. Coordinating teamwork so that there is only a unique current project status definition, as well as including team integrated work, which is also necessary for managing version controls. This coordination is likely to be the most difficult achievement.
The most ideal model is: Any member of the team can make changes to any resource you have access to you. Because the two team members can submit changes to the same resource, there is a possible conflict, and this conflict must be solved.
This model assumes that the conflict has uniqueness. But unfortunately, no source code is isolated in isolation; usually it contains implicit or explicit correlation with other resources. But the work of the source code management software is here, because it does not replace project management. Project managers must fulfill their responsibilities: coordinate the work of other members and responsible for progress, project phases, and release. In addition, source code management cannot replace communication between developers.
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.
Cvs
Fortunately, the Eclipse platform provides the ability to share code and work as a team in software projects.
The focus of the Eclipse platform architecture is the work space. Workspace maintenance builds and tests everything you need to test software projects, which contains source code and other resource files required. Workspace is maintained on the developer's local machine, but the entire team collaborates through the source code management system, and the code of different developers is collected in the source code management system. The Eclipse platform only provides built-in support for a source code management system: concurrent version control system (CVS).
CVS is the abbreviation of Concurrent Versions System. It was born in 1986, which has now been developed into the most popular source code version management solution for software developers. CVS is a client / server solution for open source management for code versions, which can be used in various platforms, including Linux and Windows NT / 2000 / XP.
Typically, the main function of CVS is to record the history of the source file. When a group of developers are engaged in the same project, CVS will leave each other. Each developer works independently in his / her own directory, then uses the CVS repository (often) merge work results to share its work.
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 own new code to the server at any time; can also be consistent with other developers by updating the latest state 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 Eclipse has a built-in CVS client that is tightly integrated with the Eclipse platform IDE, which is implemented as a separate perspective (CVS Repository Exploring perspective) for CVS interaction.
basic concepts
Head and branch (BRANCH)
CVS uses a branch model to support multiple workflows that are independent and highly dependent on each other. The branch is where the development team is used to share the working work. At any time, team members can use a branch of content as the foundation of the new job.
Your job is based on a branch when you make a local change in the Eclipse workspace. When you are ready to make other group members use your changes to your local resource files, you need to submit your work to your branch. Other developers must update from branch later. There is at least one branch each CVS repository called HEAD. HEAD represents the mainstream branch in CVS. In certain cases, there may be multiple branches in the resource library. For example, a branch may be used for normal development, while another branch may be used for experimental new technologies in the availability of current projects.
Creating a branch and publishing resources to that branch is very useful if it is not ready to change the main development stream. It is also useful for incremental patchs that create existing versions.
Module
In CVS, you can put the items in the local workspace into the Head branch of a repository, and CVS is named module. A branch can have many modules. It can be said that your project in the local workspace is a local working copy of a module. There is all modules in the HEAD branch. The module can have a submodule. The module can be copied to other branches.
Revision (Revision)
Each resource file that is modified locally belongs to a branch. When you submit this file, the CVS resource library creates a revision of this file. For example, a file is 1.1, you submit a revision. It will become a version 1.2.
Since some files are submitted frequently than other files, the reference to different files in the project may be different.
Version (Version)
The version refers to a snapshot of the current state of a module in a branch. When setting the version of the module (Tag As Version), it means that the unmodified copy of the module is created in the repository.
Generally, we will function or integrate testing on a version of the daily creation module, and will create a beta1, beta2, etc. before the project is completed, and will create a release version after the project is completed.
You should create a branch on a version (Version) to facilitate access to the branch point.
CVSNT installation
CVS originated from the UNIX / Linux platform, but there is also an implementation of CVS on the Windows platform - here we make a brief introduction to the CVSNT installation for your experimental CVS.
First go to CVSNT's homepage http://www.cvsnt.org Download the latest version.
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.
1. CVSNT can be installed on a Windows NT4 server or workstation SP6, Windows 2000 server or a professional version, Windows XP.
2. 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 names and file names, but there is still possible problems), then open the Control Panel -> System Properties -> Advanced -> Environment Variables -> System Variables PATH, add D: / App / CVSNT and save the settings.
3. Next, you can perform the installer, modify the installation directory, and complete the installation step by step.
4. 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. 5. 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 the E: / CVSNT / REPO, click the ingredient button to select E: / CVSNT / REPO as the database path prefix.
6. Click on the Add button below to add a repository root, repository root can have multiple. For example, we will / protoy as the storage root of our work items. Note that the system automatically uses the set E: / CVSNT / REPO as the path prefix.
7. 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.
8. Click Apply to save the settings, which is quite important.
9. You can now go back 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.
10. Open a command line window, enter the following command, use your actual computer IP address, Windows username, and repository root replace the contents related to polar brackets: SET CVSROOT =: PServer:
11. So far, the CVS server has been initially set, which can be used. By default, the server will automatically run as NT service. The reader can use the command line's CVS command, or various CVS clients can connect to the CVS server to perform CVS operations. However, the following we mainly describe the use of CVS systems in Eclipse supporting by built-in CVS.
Using a CVS system in Eclipse
Basic workflow
Developers can submit (commit) their own work and keep synchronization with the latest modifications to others through updates. Submission is submitted to the database with your own modification, and the update is a modification of others.
Therefore, the use of CVS in Eclipse for team development, the ideal development process should be like this:
Figure 2: Team development process
1. Before starting, ensure that the resources of all workspaces are consistent with the latest branches. 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 of the workspace. 2. Turn your local work and save your modifications locally.
3. Synchronize with the repository. After a certain phase is completed, you should synchronize with the data of the repository.
1. First, you should update (update), check all incoming changes, enter to the local, see if you will affect your work, whether you can cause conflicts, destroy integrity, etc.
2. After checking the update, you can confirm that your work and the latest BRANCH content are consistent, you can submit your own modification, labeled appropriate comments.
Set the location of the repository
First set Eclipse to connect to the CVS Server Repository, which will define the connection parameters used to select the CVS server / repository.
Switch to CVS Repository Exploring perspective, use menu Window -> Open perspect -> Other -> cvs repository expedition.
You can also set some CVS options in Eclipse, you can pass Window -> Preferences WINDOW -> Team. The specific meaning we will be discussed in the following chapters.
The following screens will appear in cvs repository expectory ...
Enter LocalHost in the Host Host, because my CVS server is in this unit.
Enter the repository name of the CVS you want to connect to in "Resource Retribution Repository", and the project data is stored under this path.
Enter your username and password on the CVS server in "Authentication Authentication".
Select PServer in the "Connection Type Connection Type", the port is no change in the default.
Note: More detailed explanation of all parameters described above, see specific descriptions of the CVSNT section, in the actual project, the acquisition of each parameter needs to contact your CVS manager.
Next, you can click Finish to complete the settings. If you choose Validate Connection on Finish, Eclipse will use the connection parameters you provide to connect the CVS repository if it fails, it will notify you.
Shared project
Developers can share it by migrating its existing project resources to the resource library.
First, right-click on the project of Eclipse's resource view (RESOURCE PERSPECTIVE) or Java view (Java perspect), select Team-> Share Project, the prompt window will appear, choose to use the known CVS database location or create a new database position. We will use the previously established connections, of course, we can define new connections, which will appear the position steps for setting the repository.
Figure 3. Sharing the local project using the CVS repository
If you click Next, you can continue to define if you use a different name different from the project as a module name in CVS. The default is the same name. The module corresponds to the directory of the CVS repository, and writes the same directory in the group's team sharing CVS repository.
Note A Synchronize window appears in the Tasks and Console in the lower right corner of Eclipse.
Synchronous view icons on the toolbar indicate the mode of synchronization (SYNCHRONIZE) view. Synchronize view has four modes of InComing (Incoming) mode, Outgoing (outgoing) mode, Incoming / Outgoing / outgoing) mode and Conflicts. When incoming mode, all resource files that need to update (Update) are listed under sync mode.
When incoming mode, all resource files that need to be submitted (Commit) is listed under the synchronization mode.
When incoming and outgoing mode, all resource files that need to update or submit (commit) are listed under the synchronization view.
When Conflicts mode, the Synchronize view lists all resource files that occurred concurrent file modified conflicts. Conflicts can be eliminated by merging (MERGE) to eliminate conflicts of different developers of different developers of the same file.
Note that now we only add a module in the CVS repository, all resource files of the project are not added to the CVS repository. Because there may be a considerable part of the resource file in a project that is not suitable for storage to the CVS repository recorded version information, such as the temporary file generated by the editor, compiles the generated .class file, or binaries generated by some compilerics, etc. Therefore, Eclipse does not automatically store all files into the database, requiring developers to manually specify those files to the CVS repository.
The synchronization view of the synchronization view is indicated by the Synchronize view now is now Outgoing mode. Now list all resource files that have not yet been added to the CVS repository in the project in the Synchronize window.
Store files into the CVS resource database and requires a step.
The first step, we need to notify the CVS repository those files will record their version information. We can select multiple files or directories in a resource perspection or synchronization (Java perspective) or synchronous (Synchronize) view, use the right click, select Team-> Add to Version Control, then you will find The gray arrow marks on these files or directories in the synchronization view are not seen. Note that these files do not record their version information in the CVS repository, just notify the CVS repository.
Step 2, we need to perform submits. We can select multiple files or directories at the resource perspection (Java perspective), use the right click, select Team-> Commit, or in the synchronize view, select multiple files or Directory, right-click, select Commit.
You will be prompted to enter a comment when submitting. For example, we can enter "project establishment" when submitted.
If you have submitted the file or directory, some of the first step add to Version Control, Eclipse will ask you to choose those files or directories to be used by Add to Version Control. After that, whenever modifications to files or items, you need to store the latest status into the CVS repository, you need to perform submits. Note that each submission will be prompted to enter a comment, which is important as a description and prompt of each state.
We need to tell Eclipse that resource files are stored in the CVS repository. We can select a file or directory, select a file or directory in a resource perspection, or a Synchronize view, select Team-> Add to .cvsignore, a dialog will appear, you What naming rules can be selected for matching the ignored files or directories.
Enable CVS resource modification
When this item is enabled, CVS will use the icon and label modification of the CVS state indicating the resource to modify the resources in the "Workbed" view.
To enable CVS modification:
1. From the main menu bar, select Windows-> Preferences.
2. In the dialog, select Workbench-> Label Decorations. This page allows all modifications defined by different plugins in the Workbench.
3. Select the CVS box to enable CVS modification.
Note: In some cases, modification may not appear immediately, because their computational cost is high. In these cases, they will be calculated in the background.
Export item
We can also create a new workstore project by importing code from the selected CVS repository branch. First, we open the CVS repository to browse the view (CVS Repository Exploring Perspective).
We can see the CVS module under the branch or version of the resource library, usually we are exporting the CVS module under the HEAD branch for primary development stream development.
Select the branch or version item you want to export and select Check Out as from the context menu.
You can choose to export the CVS module as an item, for example, we export the NTT module under the Head branch as the NTT project. If the table already has a project name NTT, you can override the existing item with the CVS module.
You can also choose to export the CVS module as part of a workbench project, for example, we export the NTT module to the SRC directory under the Prototype project. But only the folder in the project of the same CVS repository with the selected remote folder is the valid target of the exported operation. In addition, if the target item of the operation is a non-shared item, Eclipse will connect the item to the CVS repository (for example, the project will become a shared CVS project), but will ignore any content existing.
Synchronize with CVS repository
In the CVS team programming environment, synchronous resources involve two different processes: update with the latest changes to the branch and submit the latest changes to the workbench to the branch.
When making changes in the workbench, resources are saved locally. Finally, you want to submit your changes to the branch so that others can access them. At the same time, others may have submitted changes to branches. You will want to use these changes to update the workbench resources.
Update
When you are working on projects in the workshop, other members in the group may be submitted to changes to certain resource files shared in the repository. To get these changes, you can update your workbench to match the status of the branch.
You may have conflicts when updating. If you have modified a resource file locally, a conflict will be conflicted in the renewal of the resource file in the branch of the repository. First, you must understand three different types of updates.
When other developers have changed and submitted a file A:
Non-conflict updates. This update will occur when you have not modified a file locally. You can directly update file a in your work desk, match the latest content in the branch.
Conflict updates can be automatically merged. This update will occur when there is no local change to file a, but changes to changes to other developers in different lines of modifications in branches.
A conflict update cannot be automatically merged. The file A has not submitted local changes, but it is changed to one or more of the other developers in the branch in the ASCII file, or when the file A is binary (binary, it is not automatic This update will occur when merging).
You can issue an update command from two locations:
At Package- Explorer view
Select the context menu Team-> Update that needs to update the file, but we don't recommend that you "update" here.
Eclipse automatically updates local resource files for non-conflicts and conflicts that can be automatically merged. However, for conflicts that cannot be automatically combined, CVS will insert special tags in the file to indicate those rows that cannot be merged, which matches the behavior of the CVS command line, but there may be problems when combining the Eclipse automatic build mechanism.
View in synchronization (SYNCHRONIZE)
In the "Incoming" mode, select Update in the context menu that needs to be updated, for non-conflicts and conflicts that can automatically merge, Eclipse automatically update local resource files. However, for a conflict that cannot be automatically combined, the situation is slightly different when updating the Package- Explorer view, and Eclipse requires you first modifications to the manual combined parties without inserting a special tag in the file.
We should first resolve all conflicts that can automatically merge and cannot automatically merge conflicts in the Conflict mode. In the "Incoming" mode, select Context Menu Update, should only resolve all non-conflict changes.
To resolve conflicts, you can choose to perform one of the following operations in the conflict file context menu:
Override and update: You can use changes in the branch and discard your local work. This happens if you have made changes in local ways, or you realize that the revisions in the repository are better than your revision. Carefully complete the local changes, because you are substantially abandoning your work results.
Override and commit: You can submit your changes and classify the revision into a repository. This work should be done very carefully because you are essentially abandoning the results of others. In particular, changes that are overwriting may have other dependencies in the branch (eg, there may be other entry changes depending on conflicts).
Open in Compare Editor: First, you can manually merge your changes to the latest modifications in the repository, and save the merged resources locally. Then put the merged result marged, which will change the status of the file from the conflict to outgoing changes. You can choose the result of submitting this merge.
Typically, you want to adopt the third option (ie, first merge), because the other two options have work loss problems.
Make a manual merge:
1. In the Conflict mode, select a file with a conflict (represented by red arrow) in the resource file list, select Open in Compare Editor in the context menu. A Comparing Resources view will appear. In the Comparing Resources view, the local "workbench" data is represented on the left, indicating the resource library branch data on the right. You can check the difference between the data between both sides. 2. Use the resources comparison (Comparing Resources) view to merge changes, you can use some of the convenient features provided by the toolbar icon.
The entire document - Click the "Copy the entire document from right to left" button to replace the text in the local editor to the content of the branch resource.
Current Change - Use "Go to Next Difference" and "Go to Previous Difference" button to navigate to the changes you want to merge, or only click on the desired changes in the desired change in any source pane. Click "Copy the Current Change" button from right to right to overwrite highlighted segments with the corresponding modification content in the branch.
Tripartite Comparison - Use the "display ancest" button to compare the differences between the three resource versions: the resources in the "Workbench", the version of the resources submitted in the branch, the public ancestors (two conflict versions are based on the public ancestor ).
A different part of the file will highlight the difference. The conflict is displayed in red, and the incoming changes are displayed in blue, and the outgoing changes are displayed in gray.
3. Once completed the remote change into the local file, select Mark As Merged from the pop-up menu. This will mark the local file as an updated, which will change the status of the file from the conflict to outgoing changes.
submit
You can submit a modified "Workbench" resource to the repository so that other team members can view your work. Only those who work on the branch can see those changes submitted on the branch.
You can issue submission commands from two locations:
At Package- Explorer view
Select the resources you want to submit. Right-click the resource and select Team-> Commit from the pop-up menu. In the "Submit Notes" dialog box, you provide a comment for changes.
If you have conflicted when you change any file submitted by the above, the operation will fail. If this happens, you must first perform updates to resolve conflicts. Therefore, it is best to update before committing to prevent resources in the workshop and current conflicts in the branch.
If one or more of the resources submitted is new and have not been added to CVS control, you will be prompted to add these resources before executing commit.
View in synchronization (SYNCHRONIZE)
1. Select the outfix mode to display the resources you need (outgoing).
2. If there is a conflict (red arrow). Use the previous method to handle the conflict. Once all conflicts have been solved, it can be submitted.
3. In the "Submit Note" dialog box, provide a comment to the change.
Merge from branch
After creating a CVS branch and working in it, you may want to merge the change from the branch to another branch, or merged into the head. To this end, you need to understand the following:
1. Contains the name of the change or version of the change.
2. Create a version of the branch. This is the version name provided when setting the branch.
To merge changes:
1. Ensure that the merge target is loaded into the workspace. For example, if you want to merge the change into the Head, make sure that the work copy of the head branch is in the workspace.
2. Select the item and select Team-> Merge.
3. Enter the starting point of the merge. This is the version from which it creates a branch. Click Next.
4. Enter a branch or version that contains changes you want to merge. Click Finish.
5. The Resource Comparison window will open and display all differences between workspaces and branches with changes.
6. Handmade changes and then select Save; select Submit from the context menu. related resources
About CVS:
Http://www.cvshome.org, CVS Official Website, you can download the latest version of CVS (UNIX / Linux platform version) and related documents and materials, such as the official manual of Version Management With CVS. Http://laser.zhengmai.com.cn/cvstutorials.html, a Chinese CVS simple tutorial. http://www.cvsnt.org, CVSNT, CVS servers on Windows NT. Http://www.cvsnt.org/mailman/listinfo/cvsnt, the message list for the use of CVSNT. http://w1.858.telia.com/~u85831169/installcvsnt.html, some techniques and knowledge about CVSNT installation. Http://devguy.com/cvsnt, another CVSNT installation problem helps and common problems answer. About Eclipse: http://www.eclipse.org Since the official website, you can download the latest version 3.0m5 from here. http://dev.eclipse.org/viewcvs/index.cgi/~checkout ~/platform-vcm-home/docs/online/cvs_features2.0/cvs-faq.html, answered in Eclipse using CVS FAQ. More detailed specific operations, you can refer to the help included with the Eclipse software.