SVN命令行操作
svn命令和git很像啊!
svn命令和git很像啊!
今天用svn命令行提交版本的时候,碰到了这个比较麻烦的问题
svn: File already exists: filesystem 'xxx/svn/xxx/db'
搜了一下解决办法,都是需要两次commit,太麻烦。
直接在提交根目录执行以下命令
svn update path/ --accept=mine-full
一句话解决!
转自:http://java.dzone.com/articles/useful-subversion-pre-commit
The UTF-8 and TAB checks are performed on the following file suffixes
翻译一下:
检查UTF-8编码和TABs换行符只针对以下后缀文件:
注意:针对Linux
#!/bin/bash
REPOS="$1"
TXN="$2"
# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
ICONV=/usr/bin/iconv
SVNLOOKOK=1
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | wc -c`
if [ "$LOGMSG" -lt 2 ];
then
echo -e "\t That logmessage contains at least 2 alphanumeric characters. Commit aborted!" 1>&2
exit 1
fi
# Make sure that all files to be committed are encoded in UTF-8.
while read changeline;
do
# Get just the file (not the add / update / etc. status).
file=${changeline:4}
# Only check source files.
if [[ $file == *.java || $file == *.xhtml || $file == *.css || $file == *.xml || $file == *.js ]] ; then
$SVNLOOK cat -t "$TXN" "$REPOS" "$file" | $ICONV -f UTF-8 -t UTF-8 -o /dev/null
if [ "${PIPESTATUS[1]}" != 0 ] ; then
echo "Only UTF-8 files can be committed ("$file")" 1>&2
exit 1
fi
fi
done < <($SVNLOOK changed -t "$TXN" "$REPOS")
# Check files for svn:eol-style property
# Exit on all errors.
set -e
EOL_STYLE="LF"
echo "`$SVNLOOK changed -t "$TXN" "$REPOS"`" | while read REPOS_PATH
do
if [[ $REPOS_PATH =~ A[[:blank:]]{3}(.*)\.(java|css|properties|xhtml|xml|js) ]]
then
if [ ${#BASH_REMATCH[*]} -ge 2 ]
then
FILENAME=${BASH_REMATCH[1]}.${BASH_REMATCH[2]};
# Make sure every file has the right svn:eol-style property set
if [ $EOL_STYLE != "`$SVNLOOK propget -t \"$TXN\" \"$REPOS\" svn:eol-style \"$FILENAME\" 2> /dev/null`" ]
then
ERROR=1;
echo "svn ps svn:eol-style $EOL_STYLE \"$FILENAME\"" >&2
fi
fi
fi
test -z $ERROR || (echo "Please execute above commands to correct svn property settings. EOL Style LF must be used!" >& 2; exit 1)
done
# Block commits with tabs
# This is coded in python
# Exit on all errors
set -e
$SVNLOOK diff -t "$TXN" "$REPOS" | python /dev/fd/3 3<<'EOF'
import sys
ignore = True
SUFFIXES = [ ".java", ".css", ".xhtml", ".js", ".xml", ".properties" ]
filename = None
for ln in sys.stdin:
if ignore and ln.startswith("+++ "):
filename = ln[4:ln.find("\t")].strip()
ignore = not reduce(lambda x, y: x or y, map(lambda x: filename.endswith(x), SUFFIXES))
elif not ignore:
if ln.startswith("+"):
if ln.count("\t") > 0:
sys.stderr.write("\n*** Transaction blocked, %s contains tab character:\n\n%s" % (filename, ln))
sys.exit(1)
if not (ln.startswith("@") or \
ln.startswith("-") or \
ln.startswith("+") or \
ln.startswith(" ")):
ignore = True
sys.exit(0)
EOF
# All checks passed, so allow the commit.
exit 0
pre-commit.tmpl
为 pre-commit
。vim hooks/post-commit
#!/bin/sh
export LANG=zh_CN.UTF-8 # 设置UTF-8编码
SVN=/usr/bin/svn # 这里配置的是svn安装bin目录下的svn文件
WEB=/var/www/html # 要更新的目录
$SVN update $WEB --username xxxx --password xxxx
今天使用win上的phpstrom发现不能检出svn服务器上的文件,折腾了一番才发现原来是svn设置问题。
解决办法:
进入settings
按照下图设置:
这里我们指定了svn的命令行路径,CollabNet\Subversion Client
是CollabNet出的svn客户端命令行工具,换成其他的也可以,只要路径指定正确就行。
附下载地址: