New merge tool Semanticmerge, tested on SVN

This morning I saw a post of Scott Hanselman passing by on facebook:

“There’s as new code merging tool in town… “Semantic Merge – Plastic SCM” http://t.co/mlaqWnVGST Free Download of the Beta”

The welcome text on their site is very promising:

“a semantic merge tool…
that understands your code”

A project we’re working on at work is in a phase of a lot of refactoring’s. the base functionality seems to be working fine, we’re now taking care of better fault handling, better logging, better messaging, …

That includes a lot of refactoring’s, moving methods, adding log messages, updating methods in a team of 3 developers. That results in a lot of merge errors as we more then once make changes to the same files in the project.

The default text merge tool can’t handle these changes and more then once we’ve been fouling around for over an hour to get the files back to a ‘working’ state.

No SVN documentation

We still work with SVN for our internal projects. For my personal projects I’m hooked up to git in combination with GitHub as you probably can see in the different topics I blogged about before.

The guys from Semanticmerge placed some documentation how to configure the merge tool for git, TFS and Plastic SCM but they didn’t include documentation about configuring TortoiseSVN (the tool we are using).

On their UserVoice page there’s already a request for documentation on SVN and Tortoise.

Trial en error configuration

I didn’t wanted to wait for the upcoming documentation and decided to try and figure it out myself. I took the documentation for TFS for the semantic mergetool, the Diff/Merge configuration documentation on  MSDN, the Tortoise documentation (search for merge tool) and a post on stackoverflow to combine the different parameters that have to be set.

After some attempts I think I got it running.

Setting Tortoise SVN options

First start with downloading the beta of the Semanticmerge tool and install it on your system. You’ll need the location where you installed the tool, note it during installation or you’re going to have to search your system for the executable needed in the next step.

In TortoiseSVN you can set the merge tool you want to use (default TortoiseMerge), this we’ll have to change to the semanticmerge tool. Right click on a folder and choose for ‘TortoiseSVN’ and then  ‘Settings’.

image

In the settings screen go to ‘External Programs’ – ‘Merge Tool’. There you can set the path to the semanticmergetool.exe.

image

If you would try to merge now you’ll get an error message. The tool will be started but it doesn’t know witch files he have to merge. Those parameters will we have to add after the path to the executable.

After some searching I added following options:

So the complete command you have to fill out for the external merge tool:

Testing

I’ve created a test class with 3 simple methods and committed this to our SVN server.

On one virtual machine I updated the source and added some changes in the file. I moved the second method under the third method and added some dummy code.

I then committed the file back to the server. On my machine I also changed the same file. I’ve added a test class under the existing class and added some dummy code to the second method (that is still the second method in row).

When I then update my code on my machine I’ll see we have some merge errors (like expected).

image

If you then click on ‘Edit conflict’ the merge tool appears.

image

It indicates that Method2 is changed on both contributors. You can click the merge button to view how the tool automatically merge the files.

image

The moved method is nicely merged with the changes of the not moved method. Just like we wanted. The merged result:

Conclusion

At first sight (the merged class wasn’t that difficult) the tool does what it has to do. I’m going to start using it on our project now and will see if some more complex merges will have the same result.

One of the problems I’m still facing is that for SVN the file doesn’t seems to be resolved automatically. I still have to find the file and right click and choose ‘resolved’. Or you can do that on a checkin but then you have to remember witch files you’ll already merged.

It can be it’s another parameter you’ll have to add to the command line expression but I couldn’t find any documentation.

DISCLAIMER: The configuration seems to be working on my system. I’m not 100% sure it’s the correct configuration. Use it on your own risk!

UPDATE: You can also use the samentic merge tool as diff viewer in TortoiseSVN.

11 thoughts on “New merge tool Semanticmerge, tested on SVN

  1. pablo

    Thanks Bart!

    Conflicts are not yet resolved automatically because we prefer to get people used to SemanticMerge before… but it would be very, very easy to activate. In fact we didn’t do it so far on purpose, because all the tests pass with full automation 🙂

    Reply
  2. Pingback: Semanticmerge diff viewer settings for SVN | Bart De Meyer - Blog

  3. Pingback: Semantic Merge Emerges (from Beta) | rionscode

  4. Pingback: Semantic Merge Emerges (from Beta) - Rion.IO

  5. Daniel

    I have found that using the above configuration causes SemanticMerge to hang for a while when you try to merge a non-C# file. I would recommend leaving out the “-l=csharp” option from the merge configuration for this reason. Then SemanticMerge can decide on its own what the language is for the file based on the file extension, and either open the SemanticMerge proper or just open the text-based merge program for languages it doesn’t support. I personally also add in the ” –nolangwarn” to remove the pesky dialog box when SemanticMerge doesn’t support the language for the file.

    Reply
  6. Gianluigi

    I’ve tried to configure AnkSVN as suggested (“PATH-TO-semanticmergetool.exe” -s=%theirs -d=%mine -b=%base -r=%merged -sn=%yname -dn=%tname -bn=%bname -l=csharp -emt=default -edt=default) with the real path but I get a “Duplicated argiment” error.

    From my perspective it would be very useful to have a more speaking error and, eventually, a wizard that auto-set the properties like Beyond Compare or Code Compare are doing

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.