34

In Meld there is an option available to add synchronization points. Unfortunately I cannot figure out what these so called synchronization points do. I have messed around with it but it doesn't actually seem to do anything (except break live comparison).

I have checked the manual and searched around but have not been able to solve this mystery.

The option is available in the edit menu and in the context menu:

synchronization points in edit menu synchronization points in context menu

Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373
siebz0r
  • 18,867
  • 14
  • 64
  • 107
  • 2
    I was having problems with it working as well and it was because I didn't left-click into the edit window before telling meld to add a synchronization point so it was adding the sync point to the top of the file. It worked after left-clicking in one file in the correct spot, adding a sync point, and left-clicking in the other file and adding a sync point. Also, I think it has to be version 1.7+ – Bob Sep 19 '14 at 22:30

3 Answers3

19

The intention is that the user be able to set up points in each of the files being compared, which are supposed to match up. This helps the code-matching algorithm figure out how the two files relate to each other, in cases where the differences are complex.

I'm still figuring it out by trial-and-error, setting a point in one file and then a matching point in the other. It's not working as well as I'd have hoped; I've had the sync points get into a mismatch state. But it does make things noticeably better.

Joel Polowin
  • 206
  • 2
  • 2
  • 2
    Using a two-way comparison it seems to work okay. Using a three-way comparison I cannot get it to work. I'll accept the answer as I didn't state this in my question. – siebz0r Feb 12 '14 at 06:30
  • 4
    @siebz0r The three way version in my installed version 1.8.5 works as long as you set the sync point across all three files. The live update does break, but when you've resolved the section you are working on, you can just remove the sync points and continue (with live updates). Really this feature should work with sync points in just two files as per Araxis, but it's free so I guess I'm ok with it :) – Gavin Sep 08 '14 at 14:47
  • 2
    Using Meld 3.16, I have the same observations as Joel: sometimes sync points help, but other times they mysteriously don't. Naively I'd expect that sync points would be reflected in how the lines are aligned during lock scrolling (i.e., the sync points would be rigidly connected during scroll), but nothing like that happens. – Jess Riedel Dec 07 '16 at 20:19
17

Here is how to use synchronization points in Meld:

  1. Find two lines that should be matched but are considered by Meld as totally different lines
  2. Right-click on the left one, click "Add Synchronization Point"
  3. Right-click on the right one, click "Add Synchronization Point"
  4. That's it! Now Meld shows the two lines at the same level.
  5. You can add more synchronization couples, or clear all synchronization couples.

Example

In the screenshot below, you can see that the "GetSyncItemFromRemotePath" part is very similar between left and right, yet Meld fails to see this. So I insert a synchronization point on the left like this:

enter image description here

... and then I add another synchronization point on the "GetSyncItemFromRemotePath" on the right.

Here is the result:

enter image description here

It makes it much easier to spot the real differences, in this case the MIME type.

Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373
  • I'm not sure if I'm getting this right or I've confused myself, but it appears to be crucial to "Add Synchronization Point" on the left pane first, before the right one (and not in the other order). (Or maybe it doesn't matter and it's the same either way, I haven't tested again to confirm, leaving this comment here just in case.) – ShreevatsaR Apr 24 '21 at 01:24
  • Left-clicking on the line and then right-clicking to the add the point seems to be the determining factor for where the synchronization point gets added. I was able to start on the right pane or on the left. – Aaron Swan Apr 14 '22 at 22:29
  • This sounds like bad UX with room for improvement. Is there a bug report open already? – dreua Jun 13 '23 at 11:30
7

As mentioned by others, synchronization points are a way to fix the diff algorithm and tell it what matches what when it gets confused on its own.

The key to using them is to LEFT CLICK on a line before right clicking and selecting Add Synchronization Point from the popup menu or main menu. The complete solution is then:

  1. Find two lines that should be synchronized but aren't.
  2. Left click on the line in the left pane.
  3. Right click at the same place and select Add Synchronization Point.
  4. Left click on the line in the right pane.
  5. Right click at the same place and select Add Synchronization Point.

Done that way, I can adjust the diff in locations where it otherwise breaks making it a lot faster to verify my changes. When it breaks just a few lines, it's fine, when it breaks several screens of lines, it becomes tedious to compare without such a feature.

The following shows a meld diff which gets confused at the else keyword. That block on the left gets compared against the new default: block. (click on pictures to enlarge)

enter image description here

First I left clicked on the else in the left panel and then right click + "Add Synchronization Point".

Next I left clicked on the else in the right panel and again right click + "Add Synchronization Point".

The result is now correct:

enter image description here

Now I can see that just the . were changed with -> as I changed a vector of objects to a vector of shared pointer to objects.

Notice that Meld adds a black line along the place of synchronization. That makes it easier to see where you add your synchronization points.

Note: The merging feature makes use of three windows. In that case, the synchronization points have to be defined in all three windows to work.

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156