@echo on
setlocal EnableDelayedexpansion
::版本库物理地址
SET REPOS=E:\Repositories\test.cn
SET REV=%2
SET DIR=%REPOS%/hooks
SET PATH=%PATH%;
::svn主程序路径
set SVNPATH="d:/Program Files/VisualSVN Server/bin/svn.exe"
::svnlook程序地址   
set SVNLOOK="d:/Program Files/VisualSVN Server/bin/svnlook.exe"
::版本库地址
set REPOPATH=file:///e:/Repositories/test.cn/web
::站点文件夹路径,末尾的反斜杠不能少   
SET WORKING_COPY=e:\wwwroot\test.cn\
::svn账户名称
set USER=test  
::svn账户密码
set PASS=test   
::临时文件完整路径
set TEMPFILE=f:\LogFiles\FileList\www.cnsb.cn%time:~1,1%%time:~3,2%%time:~6,2%%time:~9,2%.txt

::更新
if exist "%WORKING_COPY%" (
%SVNLOOK% changed %REPOS%>>%TEMPFILE%
for /f "tokens=2 delims= " %%i in (%TEMPFILE%) do (
set m=%%i
::测试站点更新,注意对m进行字符串截取起始值
%SVNPATH% update --username %USER% --password %PASS% %WORKING_COPY%!m:~4,-1!!m:~-1,1!
)
)

::检出
if not exist "%WORKING_COPY%" (
%SVNPATH% checkout %REPOPATH% %WORKING_COPY% --username %USER% --password %PASS%
)

::删除临时文件
del /q %TEMPFILE%