简体   繁体   中英

svn: using vim to merge conflicts

I am trying see how merging in svn can be made easy.

This page mentions that external tools can be used for merging. Can vim be used as the external merge tool?

Some additional requirements:

  1. Files should be split horizontally/vertically to give a better view.
  2. Window titles should be set appropriately.

eg: as in 在此输入图像描述

Step 1:

Save the following script, eg: merger.sh:

#!/bin/sh
#


BASE=${1}
THEIRS=${2}
MINE=${3}
MERGED=${4}
WCPATH=${5}

vimdiff $MINE $THEIRS -c ":botright split $MERGED" -c ":diffthis" -c "setl statusline=MERGED | wincmd W | setl statusline=THEIRS | wincmd W | setl statusline=MINE"

Step 2:

Edit .subversion/config and add following line:

merge-tool-cmd = /path/to/merger.sh

Step 3:

When you get following options during svn merge command, select option ' l '. This is to launch external tool to resolve conflicts.

Conflict discovered in 'main.h'.
Select: (p) postpone, (df) diff-full, (e) edit,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: l

Step 4: Now vim will be opened in diff mode with 3 files - mine, theirs and merged. Make the required changes in the merged file, and do save and exit ( :wqa ).

Step 5:

Now below options will appear again, select ' r ' (to accept the merged version) now.

Select: (p) postpone, (df) diff-full, (e) edit,
            (mc) mine-conflict, (tc) theirs-conflict,
            (s) show all options: r

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM