A good SCM should be closely integrated with your work environment. No one really likes to go to the command line to add files to the repository. Eclipse has implemented CVS integration for a long time, but it has not been noticed by subversion users until recently. Now, the new subclipse plug-in provides a smooth subversion integration in eclipse.
(1) install the subclipse plug-in
Below, you install subclipse from the Update site in the usual way:
1. Open the "Find and install" window ("Help> Software Updates> Find and install ").
2. Select the search for new features to install option and click Next.
3. Click "new remote site" and create a remote site. Use the subclipse name and select the appropriate URL:
Name: subclipse 1.4.x (eclipse 3.2 +)
URL: http://subclipse.tigris.org/update_1.4.x
Name: subclipse 1.2.x (eclipse 3.2 +)
URL: http://subclipse.tigris.org/update_1.2.x
Name: subclipse 1.0.x (eclipse 3.0/3.1)
URL: http://subclipse.tigris.org/update_1.0.x
Version 1.4.x is recommended.
4. In the result installation window, select "subeclipse In the features" to the installation list and start installing the plug-in through the wizard.
5. After completing these steps, restart eclipse. Now, you can proceed!
Figure 1. Install the subclipse plug-in
(2) create a repository Definition
Now that you have installed the plug-in, you need to tell it where your project repository is located. You implemented it in the svn repository view. Open this view ("Windows> show View> Other> SVN repository") and select "New> repository location" in the context menu to display a dialog box shown in figure 2. Enter the appropriate URL and click "finish ".
Figure 2. Add a repository Definition
(3) Check out a project
Once a repository is created, you can view all the content in the svn repository view (see figure 3 ). We will see later that this view is a very convenient way to interact with subversion.
Figure 3.svn repository view.
Now, let's check out a project to your eclipse workspace. Select the desired subversion repository, open the context menu, and select "checkout. This will open a wizard with two options:
· Check out as a project configured using the new project wizard-this option opens the New Project Wizard, which allows you to use the built-in Eclipse project type configuration project. This option is usually best used because it allows you to use the same project template and configuration screen, and you often use it when you create a regular project.
· Check out as a project in the Workspace-this option simply creates an Eclipse project in your workspace that contains the checked source code.
In the above two cases, you still need to update the build path of the project, because eclipse cannot determine the location of the Java source code before detecting the source code of the project.
(4) import a new project to the warehouse
If you only start a new project, you need to import it to the Subversion repository. Subclipse provides a convenient way to implement this directly from within your ide. To do this, select your project from the package explorer view and select "Team> share project" from the context menu ". You can use one of the existing repositories or create a new repository definition. After you specify the repository and project name, you can specify the files and directories you want to put in the repository and provide an initial comment (see figure 4 ). This method is particularly useful because it allows you to selectively import files managed only by subversion, even if the project also contains other files (such as the generated class, temporary files or other non-essential content ).
Figure 4. Import a project to a subversion Repository
Use Subversion in eclipse
Now that your project that supports subversion has been started and runs, most of the necessary subversion commands can be accessed through the "team" context menu (see figure 5 ). You can view the status of your local file in package Explorer (see figure 6). Any modified file is marked with an asterisk. The files stored in the warehouse all display a small yellow bucket icon (representing a database); files not added to the warehouse are displayed with a question mark.
Figure 5. Most subversion commands can be accessed through the team menu
Figure 6. You can view the local file status in package Explorer
(1) synchronization with Repository
It is quite straightforward to update your files from the repository and submit your changes to the repository. This can be done using the "Team> Update and team> commit" menu options. Before submitting your changes, you may want to check whether any files on the server have been modified since your last update. Therefore, you can use "Team> synchronize with repository ". This command allows you to see what has been locally modified, what has been modified on the server, and any conflicts between the two changes (see figure 7 ). You can also visually view conflicting versions and correct any prominent conflicts before submitting your changes.
Figure 7. Synchronization with warehouse
(2) Use attributes
Attribute is one of the innovative features of subversion. In subversion, You can associate metadata ("properties") to any file or directory. You can define any attributes you like, but subversion also provides some useful built-in attributes, such as the Attributes provided in figure 8 below:
· SVN: executable attribute, which allows you to set an executable flag for a file on an operating system that supports this capability.
· SVN: the need-lock attribute, which can be used to forcibly apply the exclusion lock on files (such as binary files. A file defining the svn: Need-lock attribute can only be modified by one person at a time. When the file is detected, it is read-only. If you want to modify the file, you must first use the "Team> lock" menu option. Then, use "Team> unlock" to release the file, or submit your changes only. This row will release the lock and allow other users to also obtain a lock on the file.
Figure 8. Add a subversion attribute to a file
3) Tag and branch
In subversion, it is easy to create new tags and branch. You can use tags to identify a specific version (such as "Release 1.0 ").; While a branch is used for new development without affecting the primary source code base (called trunk ). Development on a branch will continue until the developer is ready to integrate the changes back to the master trunk.
In subversion, branch and tag are created by creating a virtual copy (with another name and/or another directory) for the given revision. In general, branch is stored in the branches directory and the tag is located in the tags directory, although in practice you can use any of your own customization to meet your project requirements.
From eclipse, the "Team> branch/Tag" menu enables you to create branch and tag (see figure 9 ). Among them, the Browse button provides a convenient way to view which branch and tag exist in the repository.
When you use "Team> switch" to create a new branch or tag, you can easily switch between branches. Whenever you switch to a different branch (or return to trunk), the subversion will only update the file (it needs to keep the synchronization between your current working copy and the destination branch ).
Figure 9. Create a new branch or tag
(4) revision history
Like most SCM Systems, subversion allows you to track changes in your source code. The "Team> show in resource history" menu option allows you to query the list of these changes (including changes to a file, directory, or even the entire project) (see figure 10 ).
Remember, in subversion, commit is atomic-A commit consists of a group of file changes and a global annotation. The "SVN resource history" view shows you a concise view of each submission, including modified files and related comments.
Figure 10. Historical Resources
Subversion is a powerful and flexible SCM tool and a successful successor of CVS. Combined with subclipse, subversion can be fully used in your Eclipse IDE environment.
Author: Zhu Xianzhong compiled from Tianji http://dev.yesky.com/356/2578856.shtml.
This article from [SVN Chinese network] Forward Please retain this site address: http://www.svn8.com/svnpz/20090421/4831.html
This article from [SVN Chinese network] Forward Please retain this site address: http://www.svn8.com/svnpz/20090421/4831.html