我創建了一個小shell腳本,是能夠列出自特定版本至少所有的修改,加上本地修改:
$ ./svn-modified-since 10563
代碼:
#!/bin/bash
LOCALBASE=$(svnversion -n|grep -oP "^\d+(?=M$)")
# echo "Local base revision: $LOCALBASE"
if [ ! $LOCALBASE ]
then
echo "Quit: No modifications in local copy found."
exit
fi
TARGETBASE=$1
# echo "Target base revision: $TARGETBASE"
if [ ! $TARGETBASE ]
then
echo "Quit: No target base revision given."
exit
fi
WORKPATH=$2
# files changed in working directory copy
FILES=`svn status $WORKPATH`
# files changed between working copy and foreign base revision
FILES="$FILES
`svn diff --summarize -r $TARGETBASE:$LOCALBASE $WORKPATH`"
回聲「$ FILES」 |排序-u
輸出示例:
M common_functions.php
M config.php
M locale/fr/LC_MESSAGES/fr.mo
M locale/fr/LC_MESSAGES/fr.po
M common_functions.php
? tmp/surrogates.php
...
我現在可以篩選與輸出和grep
使用文件名作爲參數與xargs
:
# ./svn-modified-since 10563 | grep -v "^\?" | grep -o "([^ ]+)$" | grep -v "config.php" | xargs svn diff --force -r 10563 > my.diff
要處理二進制文件像LC_MESSAGES,我可以通過替換svn diff命令來實現它:
svn diff --force --diff-cmd /usr/bin/diff -x "-au --binary" -r 10563
With
patch -p0 -i my.diff