svn自动从主干合入代码到分支bat命令

echo off
setlocal enabledelayedexpansion&pushd %~dp0

rem 这里假设主干和分支的根目录为:Onetrack

rem 填写在本次提交代码中,你提交了的任一文件之一,注意完成的SVN路径
set oneFile=

rem 你需要合入的Onetrack分支版本,根目录到OneTrack即可
set DestinationURL=

rem 请指定一个临时处理文件的目录
set TMP_DIR=D:\AutoMergeTempDirectory

rem 你提交的代码onetrack,SVN路径,来自oneFile
set replace=!oneFile:*/OneTrack=!
set SourceURL=!oneFile:%replace%=!


if exist "%TMP_DIR%\Onetrack" rd /s/q "%TMP_DIR%\Onetrack"
if exist "%TMP_DIR%\Onetrack" (
   echo 无法删除%TMP_DIR%目录,请手动删除
  cmd /c start %TMP_DIR%
   echo.
   pause
   goto end
)
if not exist %TMP_DIR% mkdir %TMP_DIR%

cd /d %TMP_DIR%
svn checkout %DestinationURL% --depth immediates
cd OneTrack
svn checkout %DestinationURL%/GV --depth immediates
svn checkout %DestinationURL%/Common --depth immediates
svn checkout %DestinationURL%/Feature --depth immediates
svn log %oneFile% -v -l1 -q --xml>..\svnCommitLog.xml
for /f "delims=" %%a in ('findstr "action=" %TMP_DIR%\svnCommitLog.xml') do (
set b=%%a
set b=!b:*OneTrack/=!
for /f "tokens=1,2 delims=/" %%i in ("!b!") do (
cd %%i/%%j
svn up --set-depth infinity
cd ..
cd ..
)
)
rem 获取版本号
for /f %%a in ('findstr "revision=" %TMP_DIR%\svnCommitLog.xml') do (
for /f tokens^=1-2*^ delims^=^" %%i in ("%%a") do (
set revision=%%j
)
)
echo %revision%

svn merge -c%revision% --ignore-ancestry %SourceURL% %TMP_DIR%\OneTrack
cmd /c start %TMP_DIR%
:end
pause

你可能感兴趣的:(SVN)