ads

SVN Delete permission problem

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

Monday, November 26, 2007

Delete privilege problem in SVN

This blog contain a script that will allow to control some svn user to delete the files from svn repository and also contain lock script and log message script.
Go to svn repository it contain hook scripts folder. Make a file in this folder named pre-commit.bat which contain the following scripts.
@echo off
setlocal
set REPOS=%~1
set TXN=%~2
set SVNLOOK=svnlook
set akshay=aks
: Log msg part
for /f "tokens=*" %%a in ('%SVNLOOK% author --transaction %TXN% %REPOS%') do set USER=%%a
for /f "tokens=*" %%i in ('%SVNLOOK% log --transaction %TXN% %REPOS%') do set LOGMSG="%%i"
IF DEFINED LOGMSG goto EndAll
echo. 1>&2
echo. 1>&2
echo %USER% Please enter a descriptive log message and then 1>&2
echo try to commit again. 1>&2
echo. 1>&2
echo. 1>&2
exit 1
:EndAll
: Delete part
for /f "tokens=1,2" %%b in ('%SVNLOOK% changed --transaction %TXN% %REPOS%') do (
if "%%b" == "D" (
if "%USER%" == "aks" (
echo. 1>&2
echo. 1>&2
echo %USER% you are not allowed to delete 1>&2
echo please contact ur administrator or sandeep sir. 1>&2
echo. 1>&2
echo. 1>&2
exit 1
)
if "%USER%" == "hchauhan" (
echo. 1>&2
echo. 1>&2
echo %USER% you are not allowed to delete 1>&2
echo please contact ur administrator or sandeep sir. 1>&2
echo. 1>&2
echo. 1>&2
exit 1
)
if "%USER%" == "richa" (
echo. 1>&2
echo. 1>&2
echo %USER% you are not allowed to delete 1>&2
echo please contact ur administrator or sandeep sir. 1>&2
echo. 1>&2
echo. 1>&2
exit 1
)
if "%USER%" == "akuksal" (
echo. 1>&2
echo. 1>&2
echo %USER% you are not allowed to delete 1>&2
echo please contact ur administrator or sandeep sir. 1>&2
echo. 1>&2
echo. 1>&2
exit 1
)
if "%USER%" == "akumar16" (
echo. 1>&2
echo. 1>&2
echo %USER% you are not allowed to delete 1>&2
echo please contact ur administrator or sandeep sir. 1>&2
echo. 1>&2
echo. 1>&2
exit 1
)
)
)