-
-
Save BensonleeHC/4f90bdef6048970dedee284f18ad0826 to your computer and use it in GitHub Desktop.
(svn) Export changed files between two revisions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| setlocal | |
| rem **************************************************************************** | |
| rem SVNから差分ファイルをエクスポートするバッチファイル | |
| rem 使い方: | |
| rem $ diffexport <FromRev> <ToRev> <WorkDir> <OutputDir> | |
| rem 例: | |
| rem $ diffexport 0 HEAD "c:\project" "c:\output" | |
| rem | |
| rem 必要な環境: | |
| rem - SVN を別途インストールし、実行ファイルパスを PATH に追加してください。 | |
| rem **************************************************************************** | |
| set diffexpHome=%~dp0 | |
| set diffFile=%diffexpHome%%DATE:/=%.diff | |
| set fromRev=%~1 | |
| set toRev=%~2 | |
| set workDir=%~3 | |
| set output=%~4 | |
| @for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do @set "dt=%%a" | |
| set OUTPUT_FOLDER=Patch_%dt:~0,4%%dt:~4,2%%dt:~6,2%_%dt:~8,2%%dt:~10,2%%dt:~12,2% | |
| set svn="F:\VebFile\svn1_14_2\bin\svn.exe" | |
| set output=%OUTPUT_FOLDER% | |
| set workDir=%~dp0 | |
| mkdir %output%\mod | |
| mkdir %output%\org | |
| cd %workDir% | |
| %svn% diff -r %fromRev%:%toRev% --summarize > "%diffFile%" | |
| for /f "usebackq eol=# delims=" %%z in ("%diffFile%") do call :export "%%z" | |
| del "%diffFile%" | |
| goto eof | |
| rem 一行ごとにエクスポートする処理 | |
| :export | |
| set exportLine=%~1 | |
| set filePath=%exportLine:~8% | |
| rem 先にフォルダを作らないとエクスポート時にエラーが発生する | |
| mkdir "%output%\mod\%filePath%" > nul 2>&1 | |
| mkdir "%output%\org\%filePath%" > nul 2>&1 | |
| rmdir /Q "%output%\%filePath%" > nul 2>&1 | |
| del "%output%\%filePath%" > nul 2>&1 | |
| %svn% export --force -r%toRev% "%filePath%" "%output%\mod\%filePath%" | |
| %svn% export --force -r%fromRev% "%filePath%" "%output%\org\%filePath%" | |
| set exportLine= | |
| set filePath= | |
| :eof | |
| endlocal |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
still having issue when export patch, there's a temp file for added file exist in patches. not able to find the root cause yet
cmd:
diffexport.bat 6264 6296
changes.
3 modified files
2 added files.