如何使用 Beyond Compare 3 作为 svn 的 diff3-cmd?

发布于 2024-07-24 12:04:02 字数 181 浏览 10 评论 0原文

我看到 这篇 帖子解释了如何让 BC3 工作Subversion 的 diff 工具...但是使用 Beyond Compare 3 进行三向合并/比较怎么样?

I saw this posting which explained how to get BC3 working as the diff tool for Subversion... but what about using Beyond Compare 3 to do 3-way merge/compares?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

别想她 2024-07-31 12:04:02

为此,请创建一个名为 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

To do this, create a batch file called (for example) diff3wrap.bat, and setup your diff3-cmd in your SVN config to point at it.

The following diff3wrap.bat file will do the job. It creates a temporary filename for the merge output and deletes it after returning the merged contents back to 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
ゞ花落谁相伴 2024-07-31 12:04:02

我喜欢 liamf 的批处理文件,但我认为它可能需要一个小小的调整:

我在命令调用中添加了自动合并和审查冲突,这样在合并没有冲突的情况下,它就会关闭而无需干预 - 用户界面只会弹出审查冲突。

因此,有问题的行变为:

%DIFF3% /automerge /reviewconflicts /lefttitle=%MYTITLE% /centertitle=%OLDTITLE% /righttitle=%YOURTITLE% /outputtitle="Merge Output" %MINE% %YOURS% %OLDER% %OUTPUTFILE% 

I like liamf's batch file, but I think it could take a minor tweak:

I've added automerge and reviewconflicts to the command invocation, so that in case of a merge without conflicts it just closes without intervention - the UI will only pop-up to review conflicts.

Thus, the line in question becomes:

%DIFF3% /automerge /reviewconflicts /lefttitle=%MYTITLE% /centertitle=%OLDTITLE% /righttitle=%YOURTITLE% /outputtitle="Merge Output" %MINE% %YOURS% %OLDER% %OUTPUTFILE% 
南…巷孤猫 2024-07-31 12:04:02

我只有 BC3 和 TFS 的经验,所以对此持保留态度。 三路合并是我唯一遇到问题的功能。 我不止一次必须在 BC3 中手动复制并粘贴更改才能完成合并。

I only have experience with BC3 and TFS, so take this with a grain of salt. The 3-way merge was the only feature I had problems with. More than once I had to copy and paste the changes by hand in BC3 to finish the merge.

一枫情书 2024-07-31 12:04:02

这是 liamf 脚本的 Linux 版本,适用于 svn 1.6。

#!/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

Here is a linux version of liamf's script that works with svn 1.6.

#!/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
没有伤那来痛 2024-07-31 12:04:02

这是一个 Cygwin bash 脚本,适用于 diff-cmddiff3-cmdSubversion 1.7

#!/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;

Here's a Cygwin bash script that works with Subversion 1.7 for both diff-cmd and diff3-cmd

#!/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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文