10

BC3 を Subversion の差分ツールとして機能させる方法を説明したこの投稿を見ましたが、Beyond Compare 3 を使用して 3 方向のマージ/比較を行うにはどうすればよいでしょうか?

4

5 に答える 5

8

これを行うには、(たとえば) diff3wrap.bat という名前のバッチ ファイルを作成し、それを指すように SVN 構成で diff3-cmd をセットアップします。

次の diff3wrap.bat ファイルがその役割を果たします。マージ出力の一時的なファイル名を作成し、マージされたコンテンツを SVN に戻した後に削除します。

@ECHO OFF

SET DIFF3="C:\Program Files\BeyondCompare3\BComp.exe"

REM Subversion provides the paths we need as the last three parameters
REM These are parameters 9, 10, and 11.  
REM Suitable titles for these three panes in the merge tool are in parameters 4, 6 and 8 respectively.


REM But we have access to only nine parameters at a time, so we shift our nine-parameter window
REM twice to let us get to what we need, thus changing the effective positions of the various parameters.
REM
SHIFT
SHIFT
SET MYTITLE=%2
SET OLDTITLE=%4
SET YOURTITLE=%6
SET MINE=%7
SET OLDER=%8
SET YOURS=%9
SET OUTPUTFILE=%OLDER%_%RANDOM%.merge

REM Call BeyondCompare to perform the actual merge
REM Note we give it a temporary output file and echo the output back out for SVN to use as the merged file
%DIFF3% /lefttitle=%MYTITLE% /centertitle=%OLDTITLE% /righttitle=%YOURTITLE% /outputtitle="Merge Output" %MINE% %YOURS% %OLDER% %OUTPUTFILE% 

if NOT %errorlevel% == 0 goto :mergenotcomplete

REM Merge complete. Echo the output to stdout for SVN to pick up as the result, then throw away the temporary file

TYPE %OUTPUTFILE%
del /f /q %OUTPUTFILE%
exit 0

:mergenotcomplete
exit 1
于 2009-08-31T22:15:33.773 に答える
4

私は liamf のバッチ ファイルが気に入っていますが、ちょっとした調整が必要だと思います。

コマンド呼び出しに automerge と reviewconflicts を追加しました。これにより、競合のないマージの場合は介入なしで終了します。UI は競合を確認するためだけにポップアップします。

したがって、問題の行は次のようになります。

%DIFF3% /automerge /reviewconflicts /lefttitle=%MYTITLE% /centertitle=%OLDTITLE% /righttitle=%YOURTITLE% /outputtitle="Merge Output" %MINE% %YOURS% %OLDER% %OUTPUTFILE% 
于 2010-01-27T17:43:23.167 に答える
1

これは、svn1.6で動作するliamfのスクリプトのLinuxバージョンです。

#!/bin/bash

MYTITLE=$4
OLDTITLE=$6
YOURTITLE=$8
MINE=$9
OLDER=${10}
YOURS=${11}
OUTPUTFILE=${MINE}.merge

/usr/bin/bcompare -solo -automerge -force -reviewconflicts -favorleft -lefttitle=$MYTITLE -centertitle=$OLDTITLE -righttitle=$YOURTITLE -outputtitle=$OUTPUTFILE $MINE $YOURS $OLDER $OUTPUTFILE

RESULT=$?

if [ $RESULT -eq 0 ] ; then
  cat $OUTPUTFILE
  exit 0
else
  exit 1
fi
于 2012-03-15T19:48:19.207 に答える
1

私は BC3 と TFS の経験しかないので、これは鵜呑みにしてはいけません。3 方向マージは、私が問題を抱えていた唯一の機能でした。マージを完了するために、BC3 で手動で変更をコピー アンド ペーストする必要が何度もありました。

于 2009-06-22T18:27:45.897 に答える
1

Subversion 1.7でdiff-cmddiff3-cmdの両方で動作するCygwin bash スクリプトを次に示します。

#!/bin/bash
# Set path to BeyondCompare
bcomp=~/bin/bcomp;

function bcerrlvl () {
    echo -en "$1\t";

    case $1 in
          0) echo "Success";;
          1) echo "Binary same";;
          2) echo "Rules-based same";;
         11) echo "Binary differences";;
         12) echo "Similar";;
         13) echo "Rules-based differences";;
         14) echo "Conflicts detected";;
        100) echo "Error";;
        101) echo "Conflicts detected, merge output not saved";;
          *) echo "Error";;
    esac;

    return $1;
}

if [ "$1" = "-u" ];
then
    # paths
    left=$(cygpath --dos "$6");
    right=$(cygpath --dos "$7");

    # titles
    titleleft="$3";
    titleright="$5";

    # compare command
    $bcomp -title1="$titleleft" -title2="$titleright" "$left" "$right";

    if [ $? -gt 0 ];
    then
        bcerrlvl $?;
        exit $?;
    else
        exit 0;
    fi;
elif [ "$1" = "-E" ];
then
    # Get to the tenth and eleventh arguments
    shift; shift;

    # paths
    centre=$(cygpath --dos "$7");
    left=$(cygpath --dos "$8");
    right=$(cygpath --dos "$9");
    outext="_$(date +%s)-$RANDOM.merge";
    output="$(cygpath --dos "$8")_$outext";

    # titles
    titlecentre=$2;
    titleleft=$4;
    titleright=$6;
    titleoutput="Merge Output";

    # compare command
    $bcomp -title1="$titleleft" -title2="$titleright" -title3="$titlecentre" \
        -outputtitle="$titleoutput" -automerge -reviewconflicts \
        "$left" "$right" "$centre" "$output";

    if [ $? -eq 0 ];
    then
        outfile=$(cygpath --unix "$output");
        cat $outfile
        rm -f $outfile
        exit 0;
    else
        bcerrlvl $?;
        exit $?;
    fi;
fi;
于 2012-07-12T02:15:46.240 に答える