2009-02-20 85 views
15

關注博客,我創建了一個批處理文件,wm.bat:更改默認SVN版本比較工具

"d:\svnroot\external\winmerge\WinMerge.exe" /B /WAIT "d:\svnroot\external\winmerge\WinMergeU.exe" /e /ub /dl %3 /dr %5 %6 %7 

我打過電話

svn diff | wm 

,但沒有奏效。那麼我該如何整合WinMerge或類似的工具與svn diff

擴展下面大衛的回答,改變Windows的默認需要編輯位於配置文件(適用於Windows   XP)

C:\Documents and Settings\%USERNAME%\Application Data\Subversion\config 

或(視窗  Vista)的

C:\Users\%USERNAME%\AppData\Roaming\Subversion\config 
+2

你應該在大衛的回答中加上你的回答,對他的回答進行評論,對他的回答進行編輯(通過評論清除與他的相加)或者在自己的回答中,而不是在問題本身。 – 2013-01-02 17:18:05

回答

29

好,看着original blog post,這是你想要的:

svn diff --diff-cmd wm [optional-filename] 

如果你想看看這裏實際發生了什麼(即什麼樣的參數排序svn diff通行證提名diff-cmd),你可以只使用svn diff --diff-cmd echo,看看它說:

[~/src/gosmore-dev]$ svn diff --diff-cmd echo 
Index: gosmore.cpp 
=================================================================== 
-u -L gosmore.cpp (revision 13753) -L gosmore.cpp (working copy) .svn/text-base/gosmore.cpp.svn-base gosmore.cpp 

一些報價上述被拆除,但基本上可以看到svn diff將通過

-u -L "<left-label>" -L "<right-label>" <left-file> <right-file> 

到您的批處理文件。您擁有的批處理文件用於將這些命令轉換爲WinMerge可以理解的格式。

關於如何在svn book中提供所有作品的更多詳細信息和示例。

爲了讓您的批處理文件的默認爲svn diff,你需要添加下面一行[helpers]部分在本地顛覆配置文件(~/.subversion/config在Linux中,我不知道在哪裏的配置文件位於Windows中) (見本earlier SO question

diff-cmd=wm.bat 
2

創建包含您最喜愛的合併程序的調用批處理文件後,您可以配置Subversion來一直使用Windows(批處理文件,而不需要在--diff-cmd參數每次使用)通過修改線

# diff-cmd = diff_program (diff, gdiff, etc.) 

在文件C:\ Documents and Settings \ username \ Application Data \ Subversion \ config中。這行應該改爲指向你的批處理文件。例如:

diff-cmd = c:\bin\wm.bat 
+0

在Windows 7中,此路徑已更改爲c:\ Users \ username \ AppData \ Roaming \ Subversion – 2012-03-15 16:30:31

7

退房此鏈接:

http://blog.tplus1.com/index.php/2007/08/29/how-to-use-vimdiff-as-the-subversion-diff-tool/

這裏是SOER的convienience副本:

得到這個diffwrap.sh腳本,並將其保存在任何地方。我將它保存在我的 $ HOME/bin目錄中。一定要讓 可執行!我展示它下面:

#!/bin/sh 
# Configure your favorite diff program here. 
DIFF="/usr/bin/vimdiff" 
# Subversion provides the paths we need as the sixth and seventh 
# parameters. 
LEFT="$6" 
RIGHT="$7" 
# Call the diff command (change the following line to make sense for 
# your merge program). 
"$DIFF" "$LEFT" "$RIGHT" 

# Return an errorcode of 0 if no differences were detected, 1 if some were. 
# Any other errorcode will be treated as fatal. 

然後改變你的$HOME/.subversion/config文件在該腳本指向:

[helpers] 
diff-cmd = /home/matt/bin/diffwrap.sh 

然後去DIFF文件!

3

當使用Cygwin和SVN 1.7與WinMerge時,使用此批處理文件作爲外部diff工具。我必須修改http://manual.winmerge.org/CommandLine.html才能使用Cygwin路徑。

.subversion\config:中winmergesvndiff.bat

@echo off 

set left=%6 
set right=%7 

REM Repeat these two lines for all drives 
set left=%left:/cygdrive/c/=c:/% 
set right=%right:/cygdrive/c/=c:/% 

REM Path to WinMerge may vary 
start "WinMerge" /B "C:\program files (x86)\winmerge\WinMergeU.exe" /e /s /ub /dl %3 /dr %5 %left% %right% 
0

使用Cygwin

[helpers] 
diff-cmd = C:\path\to\winmergesvndiff.bat 

內容,顛覆(Cygwin的版本)和WinDiff需要一些小心應對的斜槓後者的不寬容。我用下面的Bash腳本,通過svn的DIFF-CMD設定安裝,讓與的 'svn diff' 所期望的結果:

arg1=$(echo $6 | sed 's/\//\\/g' | sed 's/\\cygdrive\\c/c:/') 
arg2=$(echo $7 | sed 's/\//\\/g' | sed 's/\\cygdrive\\c/c:/') 
cmd /c windiff.exe $arg1 $arg2 
2

您需要的路徑到Windows風格轉換:

#!/bin/sh 

LEFT="$6" 
RIGHT="$7" 

RRIGHT=`cygpath.exe -pw $RIGHT` 
LLEFT=`cygpath.exe -pw $LEFT` 

/cygdrive/c/Program\ Files\ \(x86\)/WinMerge/WinMergeU.exe /e /s /ub /dl %3 /dr %5 $LLEFT $RRIGHT 
2

對於Mac ::

打開此文件:〜/的.subversion /配置

查找和含取消註釋行:DIFF-CMD(從開始刪除#)

在DIFF-CMD前

,給比較工具的名稱,比如在我的情況我是使用araxis合併的diff工具,所以它看起來是這樣的:

DIFF-CMD = /應用/ Araxis合併。應用程序/內容/工具/ araxissvndiff

在此之後,每當你將運行svn終端上的差異,如果將顯示在該工具中的文件的差異

確保沒有空間前後差異-CMD字。

+0

雖然空間並不重要。 – Santhosh 2016-04-12 06:44:18

2

Meld對我來說真的很棒。安裝完成後,我去Subversion配置文件,取消註釋diff-cmd行,並將其設置爲meld.exe時的路徑。在我的情況:

[helpers] 
### ... 
### Set diff-cmd to the absolute path of your 'diff' program. 
### This will override the compile-time default, which is to use 
### Subversion's internal diff implementation. 
diff-cmd = D:\SOFT\Meld\meld\meld.exe 
0

我有3個問題,用簡單的.bat文件,特別是當修正不匹配的人在工作目錄:

  • SVN可寫文件是與臨時目錄相比 - 然後在WinMerge有機會看到它們之前刪除它們
  • svn可能會從文件中提取文件。SVN \質樸的子目錄,在它的文件名是十六進制數字的長字符串
  • 的WinMerge立足於文件擴展名的語法高亮和當SVN使用臨時文件,它沒有擴展

所以我最終包裝一個小的PowerShell爲.bat文件來解決這些問題:

;@echo off 
;set leftdesc=%~3 
;set rightdesc=%~5 
;set leftfile=%~6 
;set rightfile=%~7 
;Findstr -rbv ; %0 | powershell -c - 
;goto:sCode 

&{ 
    $leftExt, $rightExt = ($env:leftdesc, $env:rightdesc) -replace '.*([.]\w+).*','$1' 
    if ($env:leftfile.EndsWith($leftExt)){ 
    $leftFile = $env:leftfile 
    }else{ 
    $leftFile = Join-Path $env:temp ((Split-Path $env:leftfile -Leaf) + $leftExt) 
    Copy-Item $env:leftfile $leftFile -Force 
    } 
    if ($env:rightfile.EndsWith($rightExt)){ 
    $rightFile = $env:rightfile 
    }else{ 
    $rightFile = Join-Path $env:temp ((Split-Path $env:rightfile -Leaf) + $rightExt) 
    Copy-Item $env:rightfile $rightFile -Force 
    } 
    $descriptions = '/dl "' + $env:leftdesc + '" /dr "' + $env:rightdesc + '"' 
    $fileNames = '"' + $leftFile + '" "' + $rightFile + '"' 
    start 'C:\Program Files (x86)\WinMerge\WinMergeU.exe' ('/e /u ' +$descriptions + ' ' + $fileNames) 
} 

;:sCode 
;goto :eof 

感謝Walid Toumi的包裝。

0

類似於上述答案的東西適用於我,但是,我的特殊設置需要一些定製。我需要對(1)在Cygwin中的「/ tmp」目錄進行修改,並且(2)確保「/ tmp」文件保持存在(因此「啓動」從Meld的啓動中消失)。

以下.bat文件爲我工作有:

  • Cygwin的(64)
  • SVN(命令行)
  • MELD
  • 的Windows 10

-

@echo off 

set left=%6 
set right=%7 

REM Repeat these two lines for all drives 
set left=%left:/cygdrive/d/=d:/% 
set right=%right:/cygdrive/d/=d:/% 
set left=%left:/tmp=c:/cygwin64/tmp% 
set right=%right:/tmp=c:/cygwin64/tmp% 

"C:\program files (x86)\meld\Meld.exe" %left% %right%