ads

search

Google

Wednesday, December 5, 2007

Lock part of the script

: Lock part
: *******************************************************
: Get the User who is committing
: *******************************************************
for /f "tokens=*" %%a in ('%SVNLOOK% author --transaction %TXN% %REPOS%') do set USER=%%a
echo user is %USER%
: *******************************************************
: Lock check - Verify that the files being committed
: have been locked by the committing user.
: *******************************************************
:LockCheck
for /f "tokens=1,2" %%b in ('%SVNLOOK% changed --transaction %TXN% %REPOS%') do (
if "%%b" == "U" (
set pass=
for /f "tokens=1,2*" %%f in ('%SVNLOOK% lock %REPOS% %%c') do (
set pass=*
: *******************************************************
: Go through the path's properties to get the owner of
: the lock.
: *******************************************************
if "Owner:" == "%%f" (
if "%USER%" == "%%g" (
echo.
) else (
goto Err
)
)
)
if DEFINED pass (
echo.
) else (
goto Err
)
)
: *******************************************************
: Make sure the files being deleted do not have locks.
: Otherwise you will have a zombie lock.
: *******************************************************
if "%%b" == "D" (
for /f "tokens=1,2*" %%f in ('%SVNLOOK% lock %REPOS% %%c') do (
goto Err
)
)
)
goto LogMessageCheck
: *******************************************************
: If there's an error display error dialogue
: *******************************************************
:Err
echo. 1>&2
echo. 1>&2
echo Please follow these guidlines: 1>&2
echo - Files being updated should be locked. 1>&2
echo - Files being deleted should NOT be locked. 1>&2
echo - Files being added should NOT be locked. 1>&2
echo. 1>&2
echo Please lock / unlock the files according to the guidlines above 1>&2
echo and then try committing again. 1>&2
echo. 1>&2
echo NOTE: DO NOT LOCK FILES THAT ARE BEING ADDED OR DELETED. 1>&2
echo. 1>&2
echo. 1>&2
exit 1