Tôi đã xem bài đăng this giải thích cách để BC3 hoạt động như công cụ khác cho Subversion ... nhưng điều gì về việc sử dụng Beyond Compare 3 để thực hiện phối hợp/so sánh 3 chiều?Làm cách nào tôi có thể sử dụng Beyond Compare 3 làm diff3-cmd cho svn?
Trả lời
Để thực hiện việc này, hãy tạo một tệp lô được gọi là (ví dụ) diff3wrap.bat và thiết lập diff3-cmd trong cấu hình SVN của bạn để trỏ vào nó.
Tệp diff3wrap.bat sau đây sẽ thực hiện công việc. Nó tạo ra một tên tệp tạm thời cho đầu ra hợp nhất và xóa nó sau khi trả về các nội dung đã hợp nhất trở lại 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
Tôi chỉ có kinh nghiệm với BC3 và TFS, vì vậy hãy dùng nó với một hạt muối. Hợp nhất 3 chiều là tính năng duy nhất tôi gặp phải sự cố. Nhiều hơn một lần tôi đã phải sao chép và dán các thay đổi bằng tay trong BC3 để hoàn thành việc hợp nhất.
tôi sử dụng BC3 qua Rùa trên Windows. Tôi có thể nói rằng các quyết định mà BC3 đưa ra luôn chính xác hơn sau đó là Tortoise hoặc chính sê-ri SVN. Tôi cũng tạo các cấu hình tùy chỉnh cho các kiểu/mẫu tệp nhất định mà tôi muốn ghi đè các giá trị mặc định. –
Tôi thích tập tin batch liamf, nhưng tôi nghĩ rằng nó có thể mất một tinh chỉnh nhỏ:
Tôi đã thêm automerge và reviewconflicts đến gọi lệnh, do đó trong trường hợp của một hợp nhất mà không mâu thuẫn nó chỉ đóng mà không có sự can thiệp - giao diện người dùng sẽ chỉ bật lên để xem xét xung đột.
Như vậy, dòng trong câu hỏi trở thành:
%DIFF3% /automerge /reviewconflicts /lefttitle=%MYTITLE% /centertitle=%OLDTITLE% /righttitle=%YOURTITLE% /outputtitle="Merge Output" %MINE% %YOURS% %OLDER% %OUTPUTFILE%
Cải tiến tốt đẹp ... Tôi đã đưa điều này vào tập lệnh hợp nhất BC3 chuẩn của mình. Cảm ơn! – liamf
Đây là một phiên bản Linux của kịch bản liamf của làm việc với 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
Dưới đây là một Cygwin bash script làm việc với Subversion 1,7 cho cả diff-cmd và 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;
Dựa trên những gì Sổ đỏ SVN đã nói về điều này, điều này có vẻ đúng ... Tôi sẽ chấp nhận câu trả lời ngay sau khi tôi kiểm tra nó. – paxos1977
Tôi vừa thử nghiệm nó và nó hoạt động (một khi bạn thay thế dòng DIFF3 thiết lập với đường dẫn cài đặt chính xác cho hộp của bạn). –