Plastic SCM features

XDiff and XMerge

Plastic SCM comes with a built-in text diff and 3-way merge tool called Xdiff/Xmerge.

Xdiff is the tool you’ll use each time you diff a file, a changeset or branch.

Xmerge is the default 3-way merge tool.

Both are highly advanced tools capable of tracking and merging code that has been moved and modified. They’re the first generation which serves as starting point to our semantic merge technology.


Xdiff identifies fragments of code that have been moved and link them to ease navigation. Xdiff use a similarity algorithm that identifies fragments of code that have been modified within a user-specified threshold. Even if the code was moved and then changed, Xdiff still detects it as the same block of code.
Xdiff lets you navigate between the fragments and run an independent diff on the moved fragment.

Moved code detection


Xmerge can detect code that:

  1. was moved by one developer
  2. and modified by other developer in parallel.
  3. And then merge correctly the code fragment and place it in the moved location.

Check Xmerge in action in the following example:
Suppose you've an initial file. And then two developers start making changes on it in parallel on its own branch: The first developer changes some code, and the second one moves that code.

Merge refactored

These changes are made on two different branches:

These changes are made on two different branches

Now let’s merge the changes from the two developers.

The changes done by the first developer are merged automatically.

Let’s merge the changes from the two developers

But let’s see what happens when we merge the changes done by the second developer.

Xmerge detects that one of the code fragments that was modified is not there on destination, so the Xmerge button shows up.

Let’s see what happens

When you click on the Xmerge button:

  1. The tool detects that the code-block that you're trying to merge has been moved.
  2. And then it finds it based on a similarity algorithm.
When you click on the Xmerge button

If the selection proposed by Xmerge is ok, you can click on “Xmerge with this selection” and then a “submerge” will merge the refactored code fragment.

Note: in case Xmerge can’t detect the moved fragment, it will ask you to find it yourself. Check the move detection preferences for details.

Xmerge submerge

The Xmerged code fragment will be placed in the right location.

Xmerge result

Once the change is checked-in this will be the Branch Explorer:

Xmerge result branch explorer

Get the latest news