Home > HowTo's > Interactive file merging with Unison

Interactive file merging with Unison

August 13th, 2009 Leave a comment Go to comments

After trying in vein to find decent documentation on the Merge functionality of Unison I eventually gave in and invested an hour or two trying out different Linux based merge programs in order to find something Unison, the merge program and I were happy with.

So onto the diff-merging candidates:

VimDiff (part of Vim)

Doesn’t work too well with Unison. I can’t get gnome-terminal (my terminal of choice) to execute synchronously so I was forced to fall back on XTerm instead.

After using XTerm I immediately hit upon a problem: there is no sensible way of outputting the results of a merge in VimDiff. Which is a pity because I do prefer VIM as an editor but this lack of functionality is annoying (yes I could have used a wrapper script but I’m trying to keep this simple).

Meld

Very pretty but lacks features such as ‘Use Left-hand-side-file for all changes’ and some of the other filtering options provided by KDiff3.

Also, like, VimDiff, does not provide any sensible output mechanism of the eventually merged file.

KDiff3

Not as good looking as Meld but provides pretty much everything I want in a merge program including the all important merged file output that Unison requires.

Can get a little annoying though with its insentient pop-up boxes. I wish there were a ‘Dont show this option again’ option to each. KDE is usually quite good with this so I’m not sure why KDiff3 managed to escape this unspoken standard.

Conclusion

So how to use KDiff3 with Unison? First install kdiff3:

apt-get install kidff3

Then open your Unison profiles .prf file and insert the following:

merge = Name * -> kdiff3 CURRENT1 CURRENT2 -L1 'Local File' -L2 'Remote File' -o NEW -m
confirmmerge = true

If you are comfortable with KDiff3 you could remove the ‘confirmmerge’ line which forces Unison to double check you actually want to accept the changes.

The downside to the above interactive merging process is there is no sensible way to preview the merge in Unison (the ‘View Merge’ button in the confirmation dialogue). For now though its preferable to not having this functionality at all.

Categories: HowTo's Tags: , ,
  1. MC
    September 1st, 2009 at 11:44 | #1

    Minor update: After discovering that my netbook (running Ubuntu 8.10) does not yet have the KDiff libraries the following URL gives the most helpful instructions for getting it installed:

    http://kapare.blogspot.com/2008/12/kdiff3-on-ubuntu-810.html

  2. September 29th, 2009 at 11:08 | #2

    gvimdiff works well for me. unison looks for changes to the temporary files CURRENT1 and CURRENT2 and applies them to the local and remote files respectively. Of course I should be able to get away with just one command, but this worked for my dot files:

    merge = Path * -> gvimdiff –nofork CURRENT1 CURRENT2
    merge = Path .* -> gvimdiff –nofork CURRENT1 CURRENT2

  3. jojo
    July 29th, 2010 at 10:43 | #3

    @Dave V
    this seems better (only one line, nofork option has two dashes on my system):

    merge = Regex .* -> gvimdiff –nofork CURRENT1 CURRENT2

  1. No trackbacks yet.
*