用meld代替svn默认的diff工具
安装meld
在Ubuntu下,只需一条简单的命令就可以了
$:sudo apt-get install meld
让svn使用meld
编辑 "~/.subversion"目录下的"config"文件,将meld赋值给diff-cmd,如下所示:
$gedit ~/.subversion/config
### 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 = meld
此后,使用svn diff命令时,将调用meld工具进行比较。
同样的方法,还可用于更改编辑器等工具:
### Set editor-cmd to the command used to invoke your text editor. ### This will override the environment variables that Subversion ### examines by default to find this information ($EDITOR, ### et al). # editor-cmd = editor (vi, emacs, notepad, etc.) editor-cmd = gedit
实践证明上述方法不可行(svn v1.6.12 | meld v1.5.0),提示如下错误:
Index: WifiEnabler.java =================================================================== Usage: meld 启动时打开空白窗口 meld <文件|目录> 开始版本控制比较 meld <文件> <文件> [<文件>] 开始两向或三向文件比较 meld <目录> <目录> [<目录>] 开始两向或三向目录比较 meld <文件> <目录> 在文件和文件夹/文件之间开始比较 meld: error: no such option: -u svn: “meld” 返回 2
原因是svn diff的参数与meld不匹配,可按如下方法更改:
让svn使用meld,新版可行的方法
1、在目录~/.subversions/下,新建脚本文件 mydiff.sh
内容如下:
#!/bin/sh
# Configure your favorite diff program here.
#"/usr/bin/bcompare"
DIFF="meld"
# DIFF="/usr/bin/meld"
# DIFF="/usr/bin/kompare"
# DIFF=env LANG=zh_CN.UTF-8 WINEPREFIX="/home/borqs/.wine" wine "C:\\Program Files\\Beyond Compare 2\\BC2.exe"
# 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.
return 0
2、更改其可执行属性
$:chmod 777 ~/.subversion/mydiff.sh
3、使svn diff命令指引到上述bash
$:gedit ~/.subversion/config
更改 diff-cmd:
diff-cmd =/home/kaigo/.subversion/mydiff.sh
参考资料: