tags:

views:

12680

answers:

3

I wanted to edit a log comment in the repo-browser and received an error message that no pre-revprop-change hook exists for the repository. Besides having a scary name, what is a pre-revprop-change hook and how do I create it?

+2  A: 

First result when googling for pre-revprop-change:

http://svnbook.red-bean.com/en/1.0/ch05s02.html

See sectoion "Hook Scripts".

Regards

/Robert

sharkin
now this link is the second one, just after a link to this question :)
ULysses
+8  A: 

Basically it's a script that is launched before any property is modified on the repository, so that you can manage more precisely what's happening on your repository.

There are templates in the SVN distrib for different hooks, located in the /hooks subdirectory (*.tmpl that you have to edit and rename depending on your OS, to activate).

PW
+32  A: 

For Windows, here's a link to an example batch file that only allows changes to the log message (not other properties): http://ayria.livejournal.com/33438.html. Basically copy the code below into a text file and name it pre-revprop-change.bat and save it in the /hooks subdirectory for your repository.

@ECHO OFF
:: Set all parameters. Even though most are not used, in case you want to add
:: changes that allow, for example, editing of the author or addition of log messages.
set repository=%1
set revision=%2
set userName=%3
set propertyName=%4
set action=%5

:: Only allow the log message to be changed, but not author, etc.
if /I not "%propertyName%" == "svn:log" goto ERROR_PROPNAME

:: Only allow modification of a log message, not addition or deletion.
if /I not "%action%" == "M" goto ERROR_ACTION

:: Make sure that the new svn:log message is not empty.
set bIsEmpty=true
for /f "tokens=*" %%g in ('find /V ""') do (
set bIsEmpty=false
)
if "%bIsEmpty%" == "true" goto ERROR_EMPTY

goto :eof

:ERROR_EMPTY
echo Empty svn:log messages are not allowed. >&2
goto ERROR_EXIT

:ERROR_PROPNAME
echo Only changes to svn:log messages are allowed. >&2
goto ERROR_EXIT

:ERROR_ACTION
echo Only modifications to svn:log revision properties are allowed. >&2
goto ERROR_EXIT

:ERROR_EXIT
exit /b 1
patmortech
Could have linked to the version there http://stackoverflow.com/questions/6155/common-types-of-subversion-hooks/68850#68850. I wrote that hook and posted it on SVN forum a while ago. I guess I should have put some credits in the hook comments.
Philibert Perusse
Worked for me, thanks!
jrummell
I'm using this script with VisualSVN 2.0.8 and TortoiseSVN 1.6.11 and it works nicely.
Mark Biek
You can edit hooks in VisualSVN by right-clicking your repository name in VisualSVN Server and selecting "Properties...". You'll see a "Hooks" tab. In there you'll see the different types of hooks available. Select the right one, click "Edit" and paste the above code into it. Hope that helps VisualSVN users!
Django Reinhardt