Showing posts with label SVN. Show all posts
Showing posts with label SVN. Show all posts

Monday, June 22, 2015

Performing SVN Merges using Eclipse plugin

In most projects automated merges are configured, this make's sure that your feature branch changes are forwarded to required future branch or trunk. But some times this may not happen, when any merge conflict arises i.e. automated merge cannot be performed or any previous revision merges on the same file are pending so your merge is waiting in queue. Or if automated forward merges are not configured, in such cases you have to manually merge the code base by resolving the conflict's if any and merge your changes into future branch or trunk and commit the changes.

In eclipse IDE Right click on the project or folder on which you want to perform merge, from context menu select Team->Merge as shown in below screen shot.


This brings up below shown merge wizard, from which you can choose type of merge you want to perform. Below I will be explaining various types of merges available.



Each of the merge type is explained below:

  1. Merge a range of revisions
  2. Use this method for performing forward merges to a branch from another branch or trunk. Typically changes from older branch are merged to newer branch.

    a. Uncheck checkbox 'Perform pre-merge best practices checks', this is to ensure no revision from older branch being missed in the subsequent wizard display. Now click on 'Next' button.

    b. In the next screen as shown below, enter (or select using 'Select' button) branch name and corresponding path from which you want to merge changes to target branch/trunk. Select option 'Select revisions on the next page' and click on Next button.



    c. It will open up window showing eligible revisions for merge (same is shown below). Select the required revisions and click Next button.



    d. It will show up conflict handling options screen, same is show below. This screen lets you take decisions for conflicts such as to prompt for each conflict or Mark conflicts and let me resolve later or Resolve conflict using your version or resolve conflict using incoming version. Once necessary option is chosen click on Finish button.



    e. Once conflicts if any are present and are resolved, go a head and commit the changes. This will ensure that you have integrated your feature branch changes into trunk or other future branch and you wont receive any more auto merge failure e-mails.

  3. Manually record merge information (block one or more revisions)
  4. This option is helpful if you want to block a revision from making into svn branch or trunk. This can typically arise if you had to stop possible successful auto forward merges to keep the latest code being over written by older code.  
    This can be achieved by choosing the 5th option in the merge wizard as shown in below screen shot. Subsequent steps are almost same as in above explained flow, you will be asked to choose the merge from branch & path and then select the revision you want to block and choose finish. This will make necessary changes in the file svn configuration and now you can commit the file. This will block the specific revision from auto merging into the SVN branch and also will not block subsequent pending merges from happening.
     

Please feel free to ask questions if you have any using comments section and also feel free to ask to cover any specific area that is missed.

Saturday, June 13, 2015

Code Merge Mantra - Handy tip for Developers

You may be writing code for either product or an application there will be multiple versions and releases involved. Some version control system such as SVN would have been employed in your organization. If you are working on a branch slated for release R1 and which is prior to release R2 in timeline then your changes has to make its way into R2 branch also.
Generally in most of the times an auto merge is configured from R1 to R2 branch, so that every change performed in R1 is automatically forwarded to R2. This may result in to couple of outcomes,
  1. One is forward merge could result in to successful merge so everything is all right.
  2. Or forward merge fails because of merge conflicts and you may be flocked with continuous mails to correct the conflict and perform manual merge in R2 branch and resolve the merge failure error.
  3. Or your merge may be waiting on other forward merges from R1 to R2 to complete. These are commits performed in R1 prior to your commits.
Both of the last two cases (2 and 3)  are painful and should be avoided all times. And worst case your R1 change not making its way into R2, which is a time-bomb and can blast during R2 release.
Here I am going to explain how to avoid and over come forward merge failures. Even though we want every thing to be automated but in real life we have to take up manual root some times. Same applies to my suggestion. After you have committed your changes into R1 wait for 5 minutes and check in R2 branch whether your changes are automatically merged? if not don't wait, perform manual merge of your changes into R2.
How to make Manual Forward Merge
Use your source control merge tool and fire up the manual merge. It asks for which branch to merge from, in this case R1. Now it lists the revisions you want to merge. Select your latest revision and perform the merge and commit your changes. This ensures that you wont get any more merge failure error mails and your changes are successfully made their way into latest branch R2.
Tips when auto merges are configured
Generally regular commits is recommended once your code is compilable and does not break any other code; but when auto merges are configured your source control system becomes double edged sword. Your every commit may result into above explained scenarios and can cause much more disturbance and work for you and several others (such as configuration management team and other developers). So best practice is commit your changes only when you have done your testing and sure that no more changes are required on the same piece of code. This will reduce the number of additional manual forward merges.