Using Subversion (SVN) Local Repository
Contributed By; Tushar Joshi
UPDATE: The subversion binary provided by tigris.org is no longer maintained as they are available from professional providers free of cost. I have changed the links to tigris.org Subversion server binaries and replaced them with collabnet links. Please note that some steps related to Subversion Server installation may be different for the new installers.
Maintaining source code of our projects in a version control software is very important for the maintenance of the project. In large projects the projects are hosted on a server bases source control repository. NetBeans support Subversion, one of the popular source control server softwares.
Subversion allows us to create local repositories also to store our projects and manage the versions on local machine. Let us look how to install Subversion, its client TortoiseSVN and then use it to store our project locally in a source control repository.
We will need two important software binary installers.
We will execute the Subversion installer to install the repository server in Windows.
NetBeans IDE checks the availability of svn.exe command in the windows executable search path which is set as an environmental variable PATH. We will need the Subversion binaries to be in our windows path so NetBeans IDE can find them and use them. We will copy the path of Subversion binaries.
This path must be set into the PATH environmental variable in windows. To set the PATH environmental variable I will right click the My Computer icon, select Properties, select Advanced tab and click the Environmental Variables button.
This will show me a dialog box for Environmental Variables. Here I will click the PATH variable and will choose the Edit button to add one more entry for the Subversion path. The paths in windows are separated with semicolons; so we will remember to add a semicolon before the path.
To check whether our Subversion binaries are really available in the windows executable path we will open a command prompt and type
This command will show me details of the installed subversion.
Note that Subversion is installed just be copying the ZIP file and extracting the archive. Then the bin path is added in the windows PATH environmental variable. To create a new repository for our local use we will use the TortoiseSVN windows shell extension client. The local repository can also be created through a command line without using the TortoiseSVN client but through TortoiceSVN it becomes easier.
We will create a new folder named svnrepo in C: drive. Then we will right click on the folder choose the TortoiseSVN > Create repository here... option and the repository will be made for me.
Tortoise will ask which type of repository is wanted and we will keep the default Native filesystem (FSFS).
Now we are ready to use the subversion version control system in our NetBeans IDE projects. Let us open the project in NetBeans and right click on the project name.
We can see the versioning option has option of Import into Subversion Repository... By choosing this option we will tell NetBeans that we want to store our project in a repository.
NetBeans IDE will ask where to keep the project, i.e. the path for the repository. There are many ways to describe the paths for Subversion repository and they depend upon how the repository is set and on what protocol it is available. As we are using the repository locally we will have to use the FILE protocol.
So we will type file:///C:/svnrepo as our path for the local repository.
We must specify the message for checking in the project into subversion repository.
NetBeans shows all the files that will be checked in the repository when the wizard completes. I will click the finish button and the project will be added to the local subversion repository. NetBeans IDE shows a visual clue attached to the project icon showing this project is now under version control.
The project when right clicked now shows a Subversion option menu and Subversion sub-menu shows options to Update and Commit the files into the repository.
As soon as there is a change in the files of the project the files are shown in different color and the visual clue is shown with the icon of the file.
When we are done with the updates we right click the file and say Subversion > Commit and NetBeans IDE offers dialog box where we have to type the commit message and then the file updates are stored in the source control repository.
This is how NetBeans makes it easy to manage the project in a local source control repository.