Pages

Thursday, February 21, 2013

SVN merge operations in eclipse


When in source control slang when we talk about “merge” we refer to the act of applying specific software changes from one version into another.
“Merge” is a very important operation when working in large projects and version control tools such as subversion are of great help to the developers(I feel confident enough to say that today without this tools it would be almost impossible to work in a large scale project).
In this post I would like to describe just one of the many scenarios where “merge” is often used in real life and how we can perform this operation with the eclipse IDE:

Scenario example:
-Team Lead: Djordje, I was informed that the last bug fix will not just go into our next release, to the pre-production environment, we will also need to apply those changes to one of our older branches.

-Djordje: We have this fix currently in preproduction so you want to apply it also to a different branch? Why is that?

 -Team Lead: Yes, one of our principal test engineers think that something might remain untested and he would like to write some more tests, since those test were initially not part of our regression test plan, we don’t want to include them  to our trunk until they are approved by a business analyst, so what we are going to do is apply the changes to a separate branch test and merge back once the testing is complete and approved.

-Djordje: Understood, just give me the details of the branch where we want to perform the testing, I will prepare the environment for the test engineer.

-Team Lead: You will have to this in the support branch 5.6
-Djordje: Thanks, I will let you know when it is ready.




So the instructions were very clear, we will need to take the changes I did commit the other day into the pre-production environment and merge them to the support branch 5.6.
The first step is to make sure that eclipse is configured to use the merge implementation from our source control provider. For that we will just go to the Preferences menu and find Diff/Merge under the SVN option.


Since we use maven as a building tool, we will right click on the root of the project or the root module(where the parent pom.xml is) and find the merge option.



In this menu, make sure that in the “From:” field you select the path to the place where the changes are and in the “To”, place the destination branch.


When you click on the “Select…” option in the top, you will be able to pick the revision that contains your changes.

Note: You will notice that the revision number appearing on the field will be  below the one you selected. This will allow the merge operation can see the changes.

Now the task is completed the only thing needed is to commit the changes made to the branch.
When the engineer in our example finishes with the testing, the new tests can be merged back into the main development branch(trunk), performing the exact same operation but this time from the branch into the trunk.

Just for finishing this post, I would like to mention that in many occasions the terminology might get us confuse in the workplace and many people(often not technical), refer to this operation as a patch.
From my point of view, a patch is something different(Soon in a separate post I will talk about how to perform a patch).




1 comment:

Share with your friends