tag:blogger.com,1999:blog-315920831118778783.post1304708007953403220..comments2023-10-29T19:00:50.054+07:00Comments on while (true) { ; }: How to Disable Steal Lock in SubversionHieu Le Trunghttp://www.blogger.com/profile/14528113575371376087noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-315920831118778783.post-42892843648141408142012-01-23T00:00:21.778+07:002012-01-23T00:00:21.778+07:00Use the following script to avoid steal lock.
@...Use the following script to avoid steal lock. <br /><br /><br />@ECHO OFF<br />:: Set all parameters. Even though most are not used, in case you want to add<br />:: changes that allow, for example, editing of the author or addition of log messages.<br />set repository=%1<br />set rev_path=%2<br />set userName=%3<br />set steal=%5<br /><br />:: If a lock exists and is owned by a different person, don't allow it<br />:: to be stolen (e.g., with 'svn lock --force ...').<br /><br /><br /><br />FOR /F "delims=: tokens=1*" %%a IN ('svnlook lock "%repository%" "%rev_path%"') DO if %%a==Owner (set LOCK_OWNER=%%b)<br /><br />:: If we get no result from svnlook, there's no lock, allow the lock to<br />:: happen:<br />if "%LOCK_OWNER%"=="" (<br />exit /b 0<br />)<br /><br />:: Check wheather the user attempt to steal or not <br /><br />if "%steal%"=="1" (<br />echo "Error: Steal lock is prohibited !!!." >&2<br />exit /b 1<br />)<br /><br /><br /><br /><br />:: If the person locking matches the lock's owner, allow the lock to<br />:: happen:<br />if "%LOCK_OWNER%" == " %username%" (<br />exit /b 0<br />)ksamyhttps://www.blogger.com/profile/15793611806251718491noreply@blogger.comtag:blogger.com,1999:blog-315920831118778783.post-61984159918523546212010-01-14T03:05:43.868+07:002010-01-14T03:05:43.868+07:00This is an old thread, but I just came across this...This is an old thread, but I just came across this link.<br /><br />Here the solution for Ashwani's problem is to check if %username% matches %AdminUser% and let the lock be set.Unknownhttps://www.blogger.com/profile/05592897906638694885noreply@blogger.comtag:blogger.com,1999:blog-315920831118778783.post-48933070797412367342009-04-29T13:13:00.000+07:002009-04-29T13:13:00.000+07:00Hi Trung,
I have ritten the script described belo...Hi Trung,<br /><br />I have ritten the script described below:-<br />But still it is not working.<br /><br />@ECHO OFF<br />:: Set all parameters. Even though most are not used, in case you want to add<br />:: changes that allow, for example, editing of the author or addition of log messages.<br />set repository=%1<br />set rev_path=%2<br />set userName=%3<br /><br />:: If a lock exists and is owned by a different person, don't allow it<br />:: to be stolen (e.g., with 'svn lock --force ...').<br /><br />FOR /F "delims=: tokens=1*" %%a IN ('svnlook lock "%repository%" "%rev_path%"') DO if %%a==Owner (set LOCK_OWNER=%%b)<br /><br /><br />:: If we get no result from svnlook, there's no lock, allow the lock to<br />:: happen:<br />if "%LOCK_OWNER%"=="" (<br />exit /b 0<br />)<br /><br />:: If the person locking matches the lock's owner, allow the lock to<br />:: happen:<br /><br />if "%LOCK_OWNER%" = " %userName%" (<br />exit /b 0<br />)<br /><br /><br />What will i do?<br />Plz help me<br />Thanks In Advanceashwanihttps://www.blogger.com/profile/15869343488526584100noreply@blogger.comtag:blogger.com,1999:blog-315920831118778783.post-67470721277915315852009-04-28T22:12:00.000+07:002009-04-28T22:12:00.000+07:00Oh I'm sorry, I've give a wrong one. It should be
...Oh I'm sorry, I've give a wrong one. It should be<br />if "%LOCK_OWNER%" = " %userName%" (<br />exit /b 0<br />)<br />if "%userName%" = "ashwanisingh" (<br />exit /b 0<br />)<br /><br /><br />The first if is to check for the lock owner is current user or not<br />The second if is to check for the user invoke the command is `admin` or notHieu Le Trunghttps://www.blogger.com/profile/14528113575371376087noreply@blogger.comtag:blogger.com,1999:blog-315920831118778783.post-1643769453026517272009-04-28T19:22:00.000+07:002009-04-28T19:22:00.000+07:00Thanks Hieu for ur suggestions.But the problem is ...Thanks Hieu for ur suggestions.But the problem is still there.The administrator(ashwanisingh) still not able to steal the lock of another user.it gives the error 'Lock Blocked by pre-lock hook(exit code 255)with output:=was unexpected at this time'<br /><br /><br /><br />I have ritten the script as below mentioned:-<br /><br /><br />@ECHO OFF<br />:: Set all parameters. Even though most are not used, in case you want to add<br />:: changes that allow, for example, editing of the author or addition of log messages.<br />set repository=%1<br />set rev_path=%2<br />set userName=%3<br /><br />:: If a lock exists and is owned by a different person, don't allow it<br />:: to be stolen (e.g., with 'svn lock --force ...').<br /><br />FOR /F "delims=: tokens=1*" %%a IN ('svnlook lock "%repository%" "%rev_path%"') DO if %%a==Owner (set LOCK_OWNER=%%b)<br /><br />:: If we get no result from svnlook, there's no lock, allow the lock to<br />:: happen:<br />if "%LOCK_OWNER%"=="" (<br />exit /b 0<br />)<br /><br />:: If the person locking matches the lock's owner, allow the lock to<br />:: happen:<br /><br />if "%LOCK_OWNER%" = "userName" (<br />exit /b 0<br />)<br />if "%LOCK_OWNER%" = " ashwanisingh" (<br />exit /b 0<br />)<br />:: Otherwise, we've got an owner mismatch, so return failure:<br />echo "Error: %rev_path% already locked by %LOCK_OWNER%." >&2<br />exit /b 1<br /><br /><br />Plz help me.ashwanihttps://www.blogger.com/profile/15869343488526584100noreply@blogger.comtag:blogger.com,1999:blog-315920831118778783.post-45484468283798868892009-04-28T18:41:00.000+07:002009-04-28T18:41:00.000+07:00You can add following lines (there is space before...You can add following lines (there is space before ashwanisingh)<br />if "%LOCK_OWNER%" = " ashwanisingh" (<br />exit /b 0<br />)<br /><br />After the line<br />if "%LOCK_OWNER%" = " %username%" (<br />exit /b 0<br />)Hieu Le Trunghttps://www.blogger.com/profile/14528113575371376087noreply@blogger.comtag:blogger.com,1999:blog-315920831118778783.post-15413478834381771262009-04-28T18:36:00.000+07:002009-04-28T18:36:00.000+07:00Hi Hieu,Thanks for suggestion
AdminName = ashwani...Hi Hieu,Thanks for suggestion<br /><br />AdminName = ashwanisingh<br /><br />I have written the below script:-<br /><br />@ECHO OFF<br />:: Set all parameters. Even though most are not used, in case you want to add<br />:: changes that allow, for example, editing of the author or addition of log messages.<br />set repository=%1<br />set rev_path=%2<br />set userName=%3<br /><br />:: If a lock exists and is owned by a different person, don't allow it<br />:: to be stolen (e.g., with 'svn lock --force ...').<br /><br />FOR /F "delims=: tokens=1*" %%a IN ('svnlook lock "%repository%" "%rev_path%"') DO if %%a==Owner (set LOCK_OWNER=%%b)<br /><br />:: If we get no result from svnlook, there's no lock, allow the lock to<br />:: happen:<br />if "%LOCK_OWNER%"=="" (<br />exit /b 0<br />)<br /><br />:: If the person locking matches the lock's owner, allow the lock to<br />:: happen:<br />if "%LOCK_OWNER%" = " %ashwanisingh%" (<br />exit /b 0<br />)<br /><br /><br />:: Otherwise, we've got an owner mismatch, so return failure:<br />echo "Error: %rev_path% already locked by %LOCK_OWNER%." >&2<br />exit /b 1<br /><br /><br /><br />This is not working.<br />Means the administrator doesn't able to steal the lock by another user which should happen.ashwanihttps://www.blogger.com/profile/15869343488526584100noreply@blogger.comtag:blogger.com,1999:blog-315920831118778783.post-31899825256943660242009-04-28T15:07:00.000+07:002009-04-28T15:07:00.000+07:00You can search for svn_owner name in the configura...You can search for svn_owner name in the configuration file with following lines<br /><br />FOR /F "delims== tokens=1*" %%a IN (%repository%\..\Permission\authz-svn.conf) DO if "%%a"=="svn_owner " ( set SVN_OWNER=%%b )<br /><br />Or if you have the administrator name already, put it into the following if<br /><br />if "%LOCK_OWNER%" = " %username%" (<br />exit /b 0<br />)<br /><br />Hope this helpHieu Le Trunghttps://www.blogger.com/profile/14528113575371376087noreply@blogger.comtag:blogger.com,1999:blog-315920831118778783.post-88990883716255985122009-04-28T14:18:00.000+07:002009-04-28T14:18:00.000+07:00It's a gr8 script.
It partly solved my problem.But...It's a gr8 script.<br />It partly solved my problem.But thanks for the person who made this script.<br />Well,How can i edit this script to allow stealing/breaking for named administrator only.<br /><br />Please help me<br />Thanks In Advance<br />Ashwani Singh<br />Senior Software Engineerashwanihttps://www.blogger.com/profile/15869343488526584100noreply@blogger.com