One of the multiple benefits of using the NetBeans IDE is that it is pre-integrated with the Subversion version control system. Whether you're developing plugins for your own private use, for customers, or for public distribution on wordpress.org, Subversion is a great system to use to keep track of all important revisions of your work over time.
This recipe explains how to use the built-in Subversion functionality in NetBeans to interact with a file repository.
You should have already installed the NetBeans IDE and created a project pointing to your local WordPress development site. You should also have created a Subversion repository on your system and imported the contents of the WordPress plugin directory.
Note
At the time of writing, an incompatibility between NetBeans 7.1 and repositories created by TortoiseSVN 1.7.x requires additional steps to be executed before performing this recipe. These steps can be found on the Netbeans website at http://netbeans.org/projects/versioncontrol/pages/Subversion1_7.
1. Using the Projects view in NetBeans, navigate to the
wp-content/plugins
directory of your WordPress installation and double-click on thehello.php
file to display it in the code editor.2. Change any line of code in the plugin header (top section of the plugin information on the plugin name, author, and so on). Notice that colored bands start appearing on the left margin of the code editor as lines are modified, added, or deleted.
3. Position the mouse cursor over the colored area that is displayed next to the modified line to see a tooltip indicating that the line has been modified.
4. Click on the colored notification area to see the previous content of that line and have the opportunity to roll back the modified content to its last known state from a previous insert, commit, or update operation.
5. In the project window, right-click on the
hello.php
file and select the Subversion | Commit menu. This command displays the NetBeans Subversion Commit interface. While it is slightly different from the equivalent TortoiseSVN dialog, you should still recognize the field used to specify a commit message and the list of all files that were identified as having changed from the last insert, commit, or update operation.7. Click on the Commit button to send your changes to the Subversion repository.
Note
By right-clicking on any file from the plugin directory and selecting the Subversion menu, we can see that all the functionalities we explored in the previous Subversion-related recipes are available in the NetBeans environment. However, some of them have different names. For example, the Show log menu item is called Search History and has some more advanced features than the TortoiseSVN client.
Similar to the way the TortoiseSVN client works, the NetBeans interface has been built using the Subversion client libraries to provide us with a full-featured tool that can access any Subversion repository. Since our WordPress plugin directory files were already imported and checked out from a repository, NetBeans is able to read the repository information that is contained in the .svn
directories located across the project structure and use this data to identify code changes on the fly during code editing. It also has access to information on the repository address that is associated to the plugin files to send new and updated items to the correct location without asking us to specify where they should be sent.