July 22, 2019

Merge code moved across files

Here is something pretty amazing. Plastic can merge methods that were moved across files.

I'm going to move a C# method to a different file in a branch.

In a different branch, I'm going to modify the original method.

Plastic merges this without human interaction and applies the change correctly in the new file.

Ta-da!

Merge scenario

This is an example scenario. I made a change on branch QUAK-104 and meanwhile another change in its parent branch:

Change in QUAK-104: move a method to a different file

This is the change in QUAK-104:

Yes, Plastic shows methods moved across files like this, with a nice visual representation.

Second change: modify the method again

Meanwhile, the change in the main branch (the parent of QUAK-104) is as follows:

Just a small modification to the method in its original location.

Trigger the mergebot

In case you haven't heard about them, mergebots run on the Plastic server, monitoring branches and triggering merges, sending the branches to Jenkins (or any other CI) to be tested, and notifying everything on your Slack, by email, etc. They can check task statuses on Jira too.



How do I trigger the mergebot now? Easy. Just set a given status attribute to the branch:

Automatic merge where any other version control would fail

Here comes the magic. One second later you see this:

Branch merged. Period. No questions asked. No human intervention.

Ta-da! Once again.

Diff the resulting changeset

Here is a diff of the resulting changeset. The change was cleanly applied to the method in its new location.

See how nicely the diffs display, highlighting the line that actually changed during the merge.

Want to test it today?

To enable a mergebot in your Plastic repo (on-premises only), configure this setting in your server.conf:

<EnableMultiFileMerge>true</EnableMultiFileMerge>

How amazing is this?

This is multi-file semantic merge in action. No other version control system comes even close to this. The whole purpose of mergebots is to offer plugin software to your repos to automate the tasks that would otherwise be manual. Turning these types of merges that would certainly require human intervention otherwise into something they solve, is pretty amazing.

We use the same technology that powers our other product, semanticmerge.com. Right now, semantic deals with C#, Java, C and C++, and we recently added PHP support.

Our ultimate goal is to have a plugin for Language Server Protocol (LSP) or even LSIF (https://code.visualstudio.com/blogs/2019/02/19/lsif) to support all possible languages.

No comments:

Post a Comment