Search code examples
svnmeld

How to set up svn conflict resolution with meld?


I've specified merge-tool-cmd = meld in my Subversion config. When I go to resolve a merge conflict using option l from the presented conflict resolution options, I receive the message:

meld: error: too many arguments (wanted 0-4, got 5)
The external merge tool exited with exit code 2

Can anyone diagnose the problem/provide a solution? Thanks.


Solution

  • First a warning! It is very easy to end up losing your local edits if you get this wrong! Test test test!

    I'm afraid the script from pmod's link does not work with svn 1.6 (current in Ubuntu 11.04). Putting together code from pmod's link and here and advice here, I made this script that seems to work ok:

    #!/usr/bin/env python
    # svn merge-tool python wrapper for meld
    import sys
    import subprocess
    
    try:
       # path to meld
       meld = "/usr/bin/meld"
    
       # file paths
       base   = sys.argv[1]
       theirs = sys.argv[2]
       mine   = sys.argv[3]
       merged = sys.argv[4]
    
       # the call to meld
       # For older meld versions:
       # cmd = [meld, mine, base, theirs, merged]
       # New meld versions: >= 1.8.4
       cmd = [meld, mine, base, theirs, '-o', merged]
    
       # Call meld, making sure it exits correctly
       subprocess.check_call(cmd)
    except:
       print "Oh noes, an error!"
       sys.exit(-1)
    

    Save this somewhere sensible (eg /usr/local/bin/svn-merge-meld.py) and make it executable:

    sudo chmod +x /usr/local/bin/svn-merge-meld.py
    

    Then edit ~/.subversion/config and uncomment the line merge-tool-cmd =, and set the path to your command.

    Note that when a conflict occurs, you will be prompted what to do with it. You need to type a single l and for svn to run this script. When you've finished your merge, you need to type an r to resolve the conflict and copy the merged version to the working copy.