Created
November 29, 2011 23:59
-
-
Save patrickmmartin/1407251 to your computer and use it in GitHub Desktop.
a little script I wrote to demo who simple branching in SVN can be, and how scriptable it is
This file contains 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 | |
:: some macros to improve legibility | |
set CHECK_DELETE= || ( echo deletion failed - exiting & exit /b ) | |
set CHECK_CREATE= || ( echo creation failed - exiting & exit /b ) | |
set CHECK_COMMIT= || ( echo commit failed - exiting & exit /b ) | |
set CHECK_READ= || ( echo read failed - exiting & exit /b ) | |
set CHECK_RENAME= || ( echo rename failed - exiting & exit /b ) | |
:: clean up | |
if exist ScratchRepo ( ( echo prior repo - deleting & rmdir /s /q ScratchRepo) | |
%CHECK_DELETE% ) | |
if exist trunk ( echo prior checkout exists - deleting & rmdir /s /q trunk) | |
%CHECK_DELETE% ) | |
if exist testbranch ( echo prior checkout exists - deleting & rmdir /s /q testbranch) | |
%CHECK_DELETE% ) | |
:: init from scratch | |
( echo creating scratch repo & svnadmin create ScratchRepo | |
%CHECK_CREATE% ) | |
:: generate the URL style REPO url | |
set REPO_URL=file:///%CD:\=/%/ScratchRepo | |
echo setting up example project in repository | |
echo this is the very first commit to this location > scratch.txt | |
( svn mkdir %REPO_URL%/trunk -m"creating trunk" --username Admin 1>nul | |
%CHECK_COMMIT% ) | |
( svn mkdir %REPO_URL%/branches -m"creating branches" --username Admin 1>nul | |
%CHECK_COMMIT% ) | |
( svn import scratch.txt %REPO_URL%/trunk/scratch.txt -m"initial revision" --username Admin 1>nul | |
%CHECK_COMMIT% ) | |
echo checking out trunk | |
( svn co %REPO_URL%/trunk trunk 1> nul | |
%CHECK_READ% ) | |
echo modifying trunk | |
echo some changes to this file > trunk\scratch.txt | |
echo copying trunk to branches/testbranch | |
( svn copy %REPO_URL%/trunk %REPO_URL%/branches/testbranch -m"copying trunk" --username Admin 1>nul | |
%CHECK_COMMIT% ) | |
echo switching WC to branches/testbranch | |
( svn switch %REPO_URL%/branches/testbranch trunk 1>nul | |
%CHECK_COMMIT% ) | |
ren trunk testbranch %CHECK_RENAME% | |
echo committing change to branches/testbranch | |
( svn commit testbranch -m"committing modifications" --username Admin 1>nul | |
%CHECK_COMMIT% ) | |
echo checking out a clean trunk | |
( svn co %REPO_URL%/trunk trunk 1> nul | |
%CHECK_READ% ) | |
echo merging testbranch back into clean trunk | |
svn merge %REPO_URL%/branches/testbranch trunk > nul |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The how
Run it on Windows in a command shell
the output on the first run will be
The result
this script creates a scratch and some branches and demonstrated a merge
the end result is a modified checkout, ready for review and commit to trunk
The point
Demonstrate branching and scripting some techniques that are useful with SVN