Tuesday, April 1, 2008

Subversion with NetBeans IDE 6.1 Beta - Source in Control

(This article expects some knowledge of Subversion source control and check-in checkout process used in version control systems)

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. Subversion the repository server binary and TortoiseSVN a windows shell client for Subversion.

I will copy the svn-win32-1.4.6.zip file which I downloaded into C: drive and will ask my 7Zip shell extension menu to extract the file right into the C: drive.

I will need the Subversion binaries to be in my windows path so NetBeans can find them and use them. I 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 I will remember to add a semicolon before the path.


To check whether my Subversion binaries are really available in the windows executable path I will open a command prompt and type svn --version. 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 my local use I 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.


I will create a new folder named svnrepo in C: drive. Then I 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 I will keep the default Native filesystem (FSFS).

Now I am ready to use the subversion version control system in my 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 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 I will type file:///C:/svnrepo as my path for the local repository.

I 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 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 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. There are many more features of the Subversion repository we shall explore one by one through future posts on this blog.

with regards
Tushar Joshi, Nagpur

9 comments:

  1. This is *super*!! Thank you so much!
    a newbie

    ReplyDelete
  2. Thanks Tushar! it Helps me a lot..

    ReplyDelete
  3. Hey I am trying subversion and when I try to commit, It says the a certain txn file has denied me access, therefore resulting n me not being ableto commit the changes. HELP

    ReplyDelete
  4. Hola a todos!!

    Buscando por ahi encontre un videotutorial que esta buenisimo.

    Es sobre subversion con www.java.net y netbeans 6.7.1

    chekenlo:)

    http://www.youtube.com/watch?v=1v5wtSP9M9k

    http://www.videojava.altainetgroup.com

    ReplyDelete
  5. This is a very useful information and helped me a lot, but I want to setup the repository on server where all the developers can use it in network.
    Could you please suggest me the way to configure this setup on Server in a local network.

    ReplyDelete
  6. @Prashant,
    You are talking about setting up a SVN repository on a machine to act as server and using it from client machines to checkin checkout code. This is beyond the subject of this blog. You can get answers on StackOverflow.com very easily.

    For now...
    you can instalkl Subversion on a machine, install SVNServe as a windows service and use that machine as a server with SVN:// protocol

    with regards
    Tushar Joshi, Nagpur

    ReplyDelete
  7. Hey,
    I was recently trying to learn using svn with googlecode and netbeans.

    I came across this problem which seems to have stuck me.
    What do we need to do if we want to stop a project from being under revision control.

    Apurv Verma (dapurv5@gmail.com)

    ReplyDelete
  8. @Apurva,

    If your project is in SVN repository just using EXPORT command from SVN command set will export your project out. This exported project will not have any version control metadata and that literally means it is out of version control. If you are using TortoiseSVN there is a context menu for exporting project out.

    with regards
    Tushar

    ReplyDelete