SVN using CLI and NetBeans

Recent exploration in the world of FOSS has helped me adopt SVN more easily than ever before. In this post, I will share some of my learnings about working with SVN using CLI and NetBeans.

Basically, I am going to map every possible command that were used on Command Line Interface (CLI), during past 2 weeks to the functionalities provided by Subversion Support in the NetBeans IDE (6.0+).

NetBeans IDE 6.7 RC2 (Click to enlarge)

Using 6.7 RC2 for demonstration,

After making project and their respective copies in the SVN repository of my plug in at Kenai. I forgot to update the /trunk after I had fixed a bug that was affecting plugin’s version v1.0, which was fixed for version v1.1. Actually, I had earlier made a tag by copying the sources from “/tags/release60_base/plugin-code-base” to “/tags/release60_fixes/plugin-code-base”.

I started fixing the code in the tagged repository before renaming/moving the repos to “/branches/release60_fixes/plugin-code-base”. Then, I realized that I had not merged the changes to the /trunk, which was required. So, we will see in the rest of this blog, how to do the merge using CLI and NetBeans IDE.

Using Command Line Interface

Now, I need the working copy of the code kept at /trunk, so I have to do a checkout, first.

svn checkout URL

You can learn more about the checkout from the book of Version Control with Subversion. I have substituted URL with https://kenai.com/svn/nbrcp-kolektiv~incubator/nbplugins/branches/release60_fixes in the above, as well as the following command(s).

Now, having read the common use-cases of Merging Whole Branch to Another in the book, I decided to give it a try using CLI. So, I did the following;

svn log --stop-on-copy URL

Here’s what the book states;

The log subcommand will normally show every change ever made to the branch, including tracing back through the copy which created the branch. So normally, you’ll see history from the trunk as well. The --stop-on-copy will halt log output as soon as svn log detects that its target was copied or renamed.

Now, this presents the required textual information, and I found out that copy was made in revision r25 and last commit was made in revision r32. Now, we know where the changes took place since making the copy of trunk in r25. As per the book, I used the following command to do the merge;

svn merge -r 25:32 URL

Firstly, change the directory to the working copy and if we use svn merge, it assumes that current directory is the working copy. So, it will apply changes that happened between r25-r32 to the working copy. It may happen that there might be some conflicts, which you can resolve from command line. Now, use the following to see the status and detect any conflicts of the working copy after merging has been done;

svn status

The console output shows only modifications (denoted by M), addition (denoted by A)/deletion (denoted by D) or conflicts (denoted by C). If there are any conflicts, they are required to be resolved. So, please refer this guide on how to resolve the conflicts using CLI. Once they are resolved, you should commit the changes to the server (/trunk).

svn commit -m some_message

where some_message = “Merged changes r25:32 into the trunk..”

Hit Enter button to send the changes to the server. The book states,

Again, notice that the commit log message very specifically mentions the range of changes that was merged into the trunk. Always remember to do this, because it’s critical information you’ll need later on.

Using NetBeans IDE

Now, I will show you how to do the same using NetBeans IDE to increase productivity, without worrying about typing issues that may occur using CLI. Also, changing directories, retrieving logs, doing manual merge, etc.

All of these may go easily wrong.. Although, its good to know how to work using CLI. Its much better to use IDE’s for the same purpose. Thus, I have written this blog that may help you switch to NetBeans IDE for the same.

Checkout..

Firstly, goto Team | Subversion menu and select Checkout… This will open a wizard where you will enter the URL, username and password. Now, refer this blog on how to checkout the code and configure it, as per the requirements. Once its done, project will be opened and displayed under Projects window.

Merge Changes..

Right-click the project node and select Subversion from the context menu. Then, select Merge Changes.. from the menu as displayed here;

Merge Changes.. (Click to enlarge)

Soon, following window opens that lets you configure the way you want the merge to happen and that too, in one step! Have  a look;

Merge Revisions (Click to enlarge)

You can see various options in the form of drop-down list and browse, search buttons. I willl brief you about the same as we move ahead. Drop-down list have three options to choose from;

Type I – One Repository Folder Since its Origin

Merge Revisions Type I (Click to enlarge)

Type II – One Repository Folder

Merge Preview Type II (Click to enlarge)

Type III – Two Repository Folders

Merge Revisions Type III (Click to enlarge)

So, I selected Type II because I want to merge changes from single repository folder (/branches/release60_fixes) which is other than the working copy, synchronized with (/trunk). This preview is shown within the same window and can be viewed by scrolling down the same window.

Browse.. will let you choose the repository folder to merge from. We will choose /branches/release60_fixes/ahrefhyperlink.revamped (This folder might change in future, you may expand /branches as shown in the figure to observe changes taken place) for merge. Have a look;

Browse Repository Folders (Click to enlarge)

At the beginning of this entry, I mentioned that one can find out that changes between which versions have to be merged in the working copy. To do that, one has to make use of svn log. In this case, one would just click the Search.. button and following window pop-up!

Log changes (Click to enlarge)

Clicking List will list all the changes that have occurred since the date entered in the shown field. As you can see tag was made in r25 and last code update took place in r32. So, we will first choose the revision #25 for Starting Revision and #32 as Ending Revision, one-by-one. See the following figure;

Merge Revisions (Click to enlarge)

This works same as the  svn merge command used earlier. Click Merge button to commence the merge operation. Once the merging is finished, one can see whether there are any conflicts or not.

Conflicts may occur, when the HEAD revision of the /trunk repository is not in sync with the other repository, when sources were first copied from /trunk. See the following figure, I got two file conflicts;

Merge Conflicts Part 1 (Click to enlarge)

For resolving conflicts, you may refer this guide written by Sun Technical Writers. Once conflicts are resolved, you must now commit the sources with this message as recommended earlier, “Merged changes r25:32 into the trunk”. That’s all for the day. Hope this helps you get started effectively.

Reference Guide
http://www.netbeans.org/kb/60/ide/subversion.html#merging

Advertisements

NetBeans Plugins at Kenai | #2

This post will focus on work flow of my plug in Revamped Hyperlink Navigation (RHN). Without much ado, lets get started..

Getting Started

Firstly, you need to access the existing sources available for plug in, published in Update Center for NetBeans 6.0 and then, I will use NetBeans 6.5 as the development software for demonstration. So, run NetBeans IDE (bundled with either Java SE, Java or All technologies).

NetBeans 6.5 boots with a b'day stamp on splash screen!

Checkout Sources..

Open Versioning | SVN menu and select Checkout… from sub-menu. Checkout Wizard opens.. Now, enter Repository URL as https://kenai.com/svn/nbrcp-kolektiv~incubator/nbplugins/tags/release60_versions and click “Next >.

You might be prompted by the NetBeans to accept certificate, click on Accept Temporarily and continue.. Now, click on the Browse button to select the Repository Folder needed to be checkout. Select /rhn_v11/ahrefhyperlink.revamped and specify your Local Folder. Also, select the checkbox with label as Scan for NetBeans Projects after checkout and click Finish. NetBeans will prompt you to open project AhrefHyperlink (Revamped). Click Open Project and NetBeans will open the project for you. Now, right-click the project node and select Properties.

Reference Guide
http://www.netbeans.org/kb/60/ide/subversion.html#checking

Manage Platforms…

Now, goto Libraries and you will notice that NetBeans Platform selected for project is the default build provided by the NetBeans 6.5 IDE, and similarly for Java Platform. So, you need to configure the project to be built against NetBeans 6.0. Therefore, refer this tips and Tricks to learn how to “Manage Platforms…“. Also, choose JDK 1.5 for Java Platform (JDK 1.6 should also work fine).

See Module in Action..

Once you are done with it, click OK to save project properties. Now, Clean and Build the project and Run to see this module in action. If success, the NetBeans 6.0 splash screen pops up and soon, NetBeans 6.0 instance is running with the plug in, installed. Try out the cases specified in the tutorial and then, try out some new one’s from your side. Observe where it works and where it doesn’t.

If you find any issues/bugs, kindly file it using JIRA Issue Tracker used for this project and select component nbm-hyperlink. Soon, I will write wikis so as to help you understand how to file issues for this project. Fixed sources are stored under /nbplugins/branches as /release60_fixes/ahrefhyperlink.revamped (Links updated).

Unstable code is placed under /nbplugins/trunk and you may see what new developments take place there.

Stay tuned for more!

NetBeans Plugins at Kenai

Do you still remember the plug in, I created last year to revamp the way hyperlink navigation was taking place for HTML files? Do you know there isn’t any such plug in yet bundled into the NetBeans IDE?

Yes/No.. Don’t say “Can’t say” 😉

Anyways, answers are Yes and No. There has never been any out-of-the-box support, that provides hyperlink navigation amongst HTML documents in the NetBeans IDE.

October 03, 2007

Geertjan Wielenga (prolific NetBeans blogger) created one, although its still not bundled with the NB, which did provide required support. There’s also a NetBeans Platform Tutorial for this plug in, you may give it a read. Although, its target release was NetBeans 6.0!

July 24, 2008

This month, I showed interest in upgrading the plug in by completing some of the tasks, specified in Next Steps section of the tutorial. You may read this blog entry for complete history and hence, I created another one. I got nice feedback from some of the community members and Geertjan, so I decided to write a tutorial for this revamped plug in.

January 09, 2009

Since, I got 2 plugins (uploaded to Plugin Portal) published into NetBeans 6.0 Update Center.. I thought why not contribute the code to the community’s codebase, i.e. contrib repository..  After interacting with the Technical Community Manager, NetBeans Dream Team and related personnel, I decided to setup a project at Project Kenai.

Today,

I decided to let you know how you can access the source code of the plug in and upgrade it according to your preferences/requirements. I am very late to notify this as I was busy with my internship program, which commenced on January 19th and culminated on 24th May (this year).

Revamped Hyperlink Navigation

…hosted at Project Kenai, you may access the source code from the SVN repository and you may also discuss about this plug in on the decidated forums. I will soon add the NBM in the downloads section, till then either you can download it from Plugin Portal (stable release) OR if you want to access it from within the NetBeans.

Update;

Then, goto Tools | Plugins and select the Settings tab. Now, click Add button and Update Center Customizer pops up. Enter Name as NetBeans UC 6.0 and URL as http://plugins.netbeans.org/nbpluginportal/updates/6.0/catalog.xml.gz. Wait for a while as NetBeans configures your new Update Center. Once done, select Available Plugins tab and you would find my plug in there. Hope this helps!

Stay tuned for more updates..

Project with Kenai and I

You all must have seen, I rarely post code on my blogs… 😮 However, during recent blog series I felt that there was indeed a need to write some code to complement my postings..

What sort of blog series?

I have been learning concepts of NetBeans Rich Client Platform for quite some time and last year, I studied RCP rather inconsistently.. So, recently focusing on design patterns, I thought of giving RCP another try and I am glad to have devoted some time to learn the popular modular framework..

What about coding?

Well, as I had blogged few months back about 2 plugins (uploaded to Plugin Portal) getting published into NetBeans 6.0 Update Center.. So, I thought why not contribute the code to the community’s codebase, i.e. contrib repository..

So, I emailed the concerned authority and after few weeks or so, got the access to the Mercurial Repository, however I had stopped working on RCP and was not able to devote much time to it..

Project (with) Kenai

I was actually thinking of setting up a project at java.net, so whenever I get time I will commit code to the SVN repository there and link to the files from blogs wherever necessary..

Also, I can have code of multiple projects committed to single project setup at java.net.. However, recently few Dream Team Members were discussing about Project Kenai on the mailing list and soon after I started exploring it.

and I

I found it interesting, so finally I have setup a project at Project Kenai and have started to commit some code..

Currently, I have stored code for my GoF and Lookup based blog series and for my Revamped Plug-in for HTML Hyperlink Navigation, I would soon add NBM’s to the downloads section..

See Also