Your corporate overlords want you to use Cleacase? Your team want to use Subversion (SVN)? Then you need my handy Clearcase to Subversion migration script. This script is based on Clearcase UCM, but can easily be adapted to run on base clearcase. We ran it from inside our builder server, and set the build script to run 5 mins after a checkin to SVN.
@echo off setlocal REM DRYRUN=-preview set PVOB=\PROJ set CC_VIEW=Z: set SVN_BASE=http://hostnname/repo/svn/trunk echo Reading current head revision svn info %SVN_BASE% | grep "Last Changed Rev" >curver.txt echo Parsing latest SVN version FOR /F "tokens=4" %%i in (curver.txt) do set REV=%%i set EXPORT_DIR=export-%REV% set EXPORT_DIR_FULL=%CD%\%EXPORT_DIR% set ORIG_DIR=%CD% set DIFF_FILE=%CD%\diff-report.txt echo Current dir is : %CD% echo Export dir is : %EXPORT_DIR% echo Export dir full is : %EXPORT_DIR_FULL% echo Exporting SVN revision %REV% to %EXPORT_DIR% svn export --force -r %REV% %SVN_BASE% %EXPORT_DIR% rem check that the export worked ok, and abort is there were problems if %ERRORLEVEL% neq 0 goto EXPORTFAILED echo Making clearcase activity cd /d %CC_VIEW%\path\src\ cleartool mkact -in stream:STREAM@\PROJ migrate_svn_%REV%@%PVOB% cleartool setact migrate_svn_%REV% echo Executing clearfsimport clearfsimport -recurse -rmname -nsetevent %DRYRUN% %EXPORT_DIR_FULL%\* %CC_VIEW%\TfSrc\J_Was\ rem check that the export worked ok, and abort is there were problems if %ERRORLEVEL% neq 0 goto IMPORTFAILED echo Checking for differences diff -r %CC_VIEW%\TfSrc\J_Was\ %EXPORT_DIR_FULL% >%DIFF_FILE% echo Creating ClearCase baseline call C:/apps/Python24/python.exe baseline.py echo Cleaning up rmdir /s/q %EXPORT_DIR_FULL% echo Migration Finished goto END :EXPORTFAILED echo Migration Failed, problem with svn export goto END :IMPORTFAILED echo Migration Failed, problem with clearfsimport goto END :END endlocal
The echo at the end is important, as you can use it to detect errors. We used Luntbuild as a build server, but cruise control would work fine too, and ran the script from within the build server. We set Lunbuild up to look for ‘Migration Finished’, if it didn’t get output, then I’d get an email informing me of the problem. Failures we usually due to the ‘evil twin‘ trigger in ClearCase rejecting the commit. If this happened I had to fix it up manually before re-runnning the script. ⓓ