Following is an installation recipe for Subversion (a free and very powerful source code control system) plus additional files for a post commit hook (so you know immediately when someone else checked something in; currently implemented as a batch file) and a backup script (so there are no excuses for not backing up your installation!). Assumptions for this recipe:
- We are creating a new repository named Corsavy
- c:\repositories is your repository root
- Backups will be located in d:\subversionbackups
Now for the recipe:
1) Install Subversion (WIN32 download). Modify the PATH environment variable so that it contains the path to your Subversion installation (usually c:\Program Files\Subversion\bin).
2) Create a repository
mkdir c:\repositories
svnadmin create c:\repositories\corsavy
Details can be found here.
3) Edit svnserve.conf (do not forget to uncomment [General]). Details see previous link, however, svnserve.conf does come with plenty of instructions itself.
4) Install Subversion as a service using the SVN Service Wrapper (Note: you have to place it in the bin directory where svnserve.exe is located)
SVNService -install -d -r c:\repositories
5) Optional: a commit hook, post-commit.bat
Put it into c:\repositories\corsavy\hooks, it will be picked up automatically
SET REPOS=%1
SET REV=%2
SET LOG_FILE=%TEMP%.\svnfileR-%REV%
SET LOG_FILE1=%TEMP%.\svnfileR1-%REV%
SET LOG_FILE2=%TEMP%.\svnfileR2-%REV%
SET AUT_FILE=%TEMP%.\svnfileA-%REV%
svnlook info -r %REV% %REPOS%>%LOG_FILE1%
svnlook changed -r %REV% %REPOS%>%LOG_FILE2%
copy %LOG_FILE1%+spacer.txt+%LOG_FILE2%+spacer.txt+%LOG_FILE%
svnlook author -r %REV% %REPOS%>%AUT_FILE%
REM SET THE AUTHOR FROM THE FILE.
FOR /F %%A IN (%AUT_FILE%) DO SET AUTHOR=%%A
blat "%LOG_FILE%" -to "toaddr" -f "fromaddr" -server localhost -s "[svn-corsavy] rev %REV%, %AUTHOR%"
DEL %LOG_FILE%
DEL %LOG_FILE1%
DEL %LOG_FILE2%
DEL %AUT_FILE%
Note that I did remove toaddr and fromaddr in this script (put in the ones you'd like to use instead), and you need a file named spacer.txt (mine simply contains four newlines). For mailing out the change log, blat is used (Note: the line with blat must not wrap). I placed blat into the bin folder of my Subversion installation, so it is automatically in the search path.
6) Optional: backup, a VBS script
Set objWsh = WScript.CreateObject("WScript.Shell")
strCmdLine = "cmd /c rmdir d:\subversionbackups\current /s /q"
nRetVal = objWsh.Run(strCmdLine, 1, True)
strCmdLine = "cmd /c mkdir d:\subversionbackups\current"
nRetVal = objWsh.Run(strCmdLine, 1, True)
strCmdLine = "svnadmin hotcopy c:\repositories\corsavy d:\subversionbackups\current --clean-logs"
WScript.Echo strCmdLine
nRetVal = objWsh.Run(strCmdLine, 1, True)
strFilename = """d:\subversionbackups\"
strFilename = strFilename & Year(Date) & Month(Date) & Day(Date) & ".zip"""
strCmdLine = "zip -r " & strFilename & " ""d:\subversionbackups\current\*.*"""
WScript.Echo strCmdLine
nRetVal = objWsh.Run(strCmdLine, 1, True)
The Zip component in use is Info-ZIP, which is free. The VBS file is run from a scheduled task each night.
That concludes the recipe for installing Subversion - well, almost: the port used by svnserve is 3690 (TCP as well as UDP), so you might need to change the IPSec policy of your server to allow those incoming ports. Same thing client-side, but this time outgoing.