windows平台下的SVN经验技巧,不断增加中....

来源:百度文库 编辑:神马文学网 时间:2024/04/28 18:14:20
  • 强制设定commit时写一定长度的日志的两种方法:

1.在客户端配置

使用客户端工具:TortoiseSVN
在工作副本目录上,鼠标右键,TSVN,选属性,点增加
再出现的下拉条中选tsvn:logminsize
然后设定必须输入的字节数就可以

2.在服务器端配置

在库的hooks目录下编写脚本(其实就是批处理文件)文件:pre-commit.bat
内容为:

@echo off
setlocal
set REPOS=%1
set TXN=%2
rem check that logmessage contains at least 30 characters
c:\svnlook log "%REPOS%" -t "%TXN%" | findstr ".............................." > nul
if %errorlevel% gtr 0 goto err
exit 0
:err
echo that logmessage contains at least 30 alphanumeric characters. Commit aborted! 1>&2
exit 1

想修改限制长度只需要增加或减少".............................."中点的数量。


总结:两种方法都可以,推荐用第二种方法,这才能起到强制的作用。第一种办法谁都可以改,强制不了,只能靠自觉。 
  • 允许修改历史日志的方法

默认是不允许修改的。

hooks目录下加入一个批处理文件:pre-revprop-change.bat

@ECHO OFF

set repos=%1
set rev=%2
set user=%3
set propname=%4
set action=%5
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Only allow changes to svn:log. The author, date and other revision
:: properties cannot be changed
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if /I not '%propname%'=='svn:log' goto ERROR_PROPNAME
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Only allow modifications to svn:log (no addition/overwrite or deletion)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if /I not '%action%'=='M' goto ERROR_ACTION
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Make sure that the new svn:log message contains some text.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set bIsEmpty=true
for /f "tokens=*" %%g in ('find /V ""') do (
 set bIsEmpty=false
)

if '%bIsEmpty%'=='true' goto ERROR_EMPTY
goto :eof
:ERROR_EMPTY
echo Empty svn:log properties are not allowed. >&2
goto ERROR_EXIT
:ERROR_PROPNAME
echo Only changes to svn:log revision properties are allowed. >&2
goto ERROR_EXIT
:ERROR_ACTION
echo Only modifications to svn:log revision properties are allowed. >&2
goto ERROR_EXIT
:ERROR_EXIT
exit 1

然后用TortoiseSVN->显示日志->选择待修改日志->右键:编辑日志信息。

但存在一个问题强制设定commit时写一定长度的日志功能失去