Saturday, July 28, 2007

Using Subversion for NetBeans on Windows XP

Any programmer by now knows the value of having a source versioning and change management facility. A day comes when you mess up existing programs or lose your work, and that's where you can check out the latest working version from a repository somewhere. Beyond that, other benefits of using SCM include source code control and configuration management.
Because of simplicity and cost (free), I decided to use Subversion as the SCM solution. Subversion is designed to replace CVS, which I've had some trouble with. My latest aggravation comes from CVS's popular error message "cvs [server aborted]: Couldn't chdir to working directory : Invalid argument" (2.0.51d). Rather than try to resolve the issue, I decided it was time to find another solution, thus Subversion.

We've come to a point in development where we are making a lot of changes to the timecard utility. In order to preserve all our work, we should start checking it into a repository. This will also allow us to branch the application and merge changes from various contributors.
Here's the process for installing Subversion n Windows XP and to use it in NetBeans 6.0 (M10).
  1. Download Subversion from http://subversion.tigris.org/project_packages.html. Choose the binary executables under the Windows section. I'm using version 1.4.4.
  2. Run the executable and note the install directory (C:\Program Files\Subversion).
  3. Add environment variables: SVN_EDITOR = C:\Windows\notepad.exe (to use Notepad as the log editor), and to PATH += C:\Program Files\Subversion\bin (NetBeans needs this).
  4. Create a database directory that'll hold your versioned projects (J:\Subversion). Use the usual Windows Explorer for this.
  5. I want all my NetBeans projects to be versioned under the NetBeans directory in the SVN database. So we create a repository as such - at command prompt, svnadmin create "J:\Subversion\NetBeans". A directory should appear under your SVN database (#4).
  6. The repository in #5 above has a conf directory. Open the svnserv.conf and uncomment anon-access = read, auth-access = write, and password-db = passwd. Save that file.
  7. Open the passwd file with a text editor and add a user under [users] in the form username = password. Save the file.
  8. Create a windows service for SVN: at the command prompt, run sc create svnserver binPath= "\"C:\Program Files\Subversion\bin\svnserve.exe\" --service --root J:\Subversion --listen-port=6043 --listen-host=localhost" DisplayName= "Subversion Repository" depend= Tcpip. Startup is manual, so visit the Services applet and set how you want it to start, and start it.
In NetBeans, import the project into SVN:
  1. Right-click the project -> Versioning | Import Into SVN Repository ...; repository url = svn://localhost:6043/NetBeans, enter the username and password specified earlier. [Next].
  2. Repository folder defaults to the project folder name. I'd leave it like that. [Finish].
That's all! At the completion of each task, you should check your work in. If multiple developers work on the project, synchronize your local workspace with the latest from SVN.

5 comments:

Mark Siedle said...

Thanks for these instructions ...I'd tried some others but they kept failing when I tried to start the service. Your instructions worked no problems :-)

Jackline said...

Hi Nice Blog .If your time is less valuable, then it is probably less worthwhile to web based timecard.

Anonymous said...

Thank you very much for posting these instructions, which finally made it work for me and saved me wasting my time any further trying to figure out how to make it work.

Zeeshan A Zakaria said...

Wonderful.

Tmip said...

Thanks so much, It's so helpful for me.