AyriA ([info]ayria) wrote,

Windows and SVN hooks

If you ever need to allow edits to commit logs, all you need to do is create a pre-revprop-change hook.

Just save this as "pre-revprop-change.bat" and throw it in the hooks directory.

@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


Nothing else useful here.
Tags: svn, work

  • Post a new comment

    Error

    Your IP address will be recorded 

  • 32 comments

[info]roju

August 17 2007, 01:48:13 UTC 4 years ago

And then what? Is it a simple svn propset to actually change it? There are too many people at my office putting in "--" as their log messages, I wouldn't mind having a tool to fix those up.

[info]sfllaw

August 17 2007, 02:11:59 UTC 4 years ago

This hook is only to sanity-check someone using `svnadmin setlog`.

Of course, they could just --bypass-hooks, but who would do that?

[info]ayria

4 years ago

[info]pphaneuf

August 17 2007, 02:45:27 UTC 4 years ago

Wow, that was both stunningly geeky and amazingly unapplicable for most hackers I know.

That's not an easy feat!

And now you're not a dinosaur anymore... ;-)

[info]ayria

August 30 2007, 20:03:16 UTC 4 years ago

I can't help that we use Windows here for almost everything. The team opted for a Windows SVN server.

Anonymous

February 29 2008, 19:18:25 UTC 4 years ago

Thanks

Useful script. Just what I was looking for. Thanks for posting it!

Anonymous

April 14 2008, 14:39:25 UTC 4 years ago

Re: Thanks

I've got a problem with my pre-revprop-change.bat.
It will not execute.
It's not the file itself, no matter what I put into it, it never gets executed.
Shouldn't this hook be run every time I add/change/remove a property in the repository?

Anonymous

June 11 2008, 19:38:59 UTC 3 years ago

THANK YOU!

Thank you soooooo much for the script! I've been looking for this for awhile.

--corcoranp

Anonymous

June 24 2008, 10:19:12 UTC 3 years ago

Thanks

Thanks. It's work.

Anonymous

July 2 2008, 12:57:15 UTC 3 years ago

Seems to be working

Hello,
it seems to be working, but I have an Issue.
When I try to change an existing log to an empty string via TortoiseSVN or via svn command line client than I get this error:

DAV request failed; it's possible that the repository's pre-revprop-change hook
either failed or is non-existent
At least one property change failed; repository is unchanged
Error setting property 'log':
Could not execute PROPPATCH.

But I should get instead an "Empty svn:log messages are not allowed" error message.

I did additional test and I've discovered, that the pre-revprop-change.bat is called twice.
At the first time it is called for the new empty log message, the result is 1 because empty is not allowed (exit 1)
At the second time it is called for the previous non-empty log message, the result is 0 becaus non-empty is allowed (exit 0)

It seems that SVN gets an error (empty is no alowed) and that it tries to set back the previous svn:log value. In that case there are errors, but nothing is in the stderror, so no custom error message is displayed.

Does anyone get the same error?

Anonymous

July 2 2008, 13:07:41 UTC 3 years ago

Re: Seems to be working

An addition:

I've tried to set an empty log on a revision that is already empty.
In this case the hook is called twice too, but in both the return value is 1 and the user can see "Empty svn:log messages are not allowed" error message.

Regards Tomas Bihary

Anonymous

3 years ago

Anonymous

3 years ago

Anonymous

1 year ago

Anonymous

July 12 2008, 00:52:05 UTC 3 years ago

Thanks $1,000,000.00

This was just what I needed

Anonymous

July 14 2008, 14:22:36 UTC 3 years ago

Big thx! It's work perfectly!

Anonymous

August 27 2008, 06:48:23 UTC 3 years ago

Thanks

Thank you for this script! Works perfect! This was just what I was looking for:)

Anonymous

October 10 2008, 18:47:48 UTC 3 years ago

Thanks

Saved me a LOT of head ache....

Anonymous

January 7 2009, 04:18:02 UTC 3 years ago

Thanks

Thanks a lot. I found it after an hour of head bashing though. :) Thank you.

Anonymous

January 15 2009, 20:27:02 UTC 3 years ago

Thanks a lot

It's seems to work and it really saved me a lot of time.

Thanks once again, it was really helpful

[info]gdy

February 10 2009, 14:32:31 UTC 3 years ago

Thanks! Google had found exactly what I wanted when I asked for "pre-revprop-change.bat" ;-)

Anonymous

March 27 2009, 10:41:57 UTC 3 years ago

Thanks

I was looking for a solution to adding comments and this works lovely.
I don't suppose anyone would know if it is possible to automate the process of adding this .bat when a new repository is created would they?

Anonymous

July 21 2009, 19:44:38 UTC 2 years ago

Possible bug

I think there's a bug in this otherwise very helpful batch file.

The test to make sure that the new svn:log message is not empty does not appear to work. It tests the last parameter on the command line. But the log message is not passed to the batch file as a parameter. It is passed via STDIN. This is documented in the pre-revprop-change template that comes with Subversion (version 1.6.3 (r38063). I'm running XP Pro SP 2 on both my PC and the Subversion repository PC.

Unfortunately, I have not been able to find a way to test whether STDIN is empty in this batch file. Does anyone else know how to do this?

Anonymous

September 16 2009, 20:19:42 UTC 2 years ago

Is it possible to edit the message that is beein alterd and add a line at the end like "Last edited by userName" ?

Anonymous

October 5 2009, 20:56:47 UTC 2 years ago

thanks

Really appreciate not having to write this manually. Greate script

Anonymous

February 18 2010, 16:55:29 UTC 2 years ago

Thanks a lot

I'm very glad not to be forced to figure all that out by myself.
Saved me hours!
Thanks!

Anonymous

March 10 2010, 16:37:13 UTC 2 years ago

great

works great, thanks for sharing it.

Anonymous

March 16 2010, 15:53:09 UTC 2 years ago

Awesome!

Save me tons of time - now I could go to bed. Thank you!

Anonymous

August 10 2010, 09:02:52 UTC 1 year ago

Thanks!

It works! :)

Anonymous

January 12 2011, 03:18:54 UTC 1 year ago

Vita subsided least you olph dreaded could fuse fed the mbc.

Happy Reborn Year[url=http://sdjfh.in/flexpen/],[/url] everyone! :)

Anonymous

January 22 2011, 11:30:50 UTC 1 year ago

Worked AS IS.. Thanks

Worked on W2K3 server as is, copied code to pre-revprop-change.bat and copied to each repo's hooks folder.

Anonymous

February 16 2011, 10:18:45 UTC 1 year ago

archi vendita

Hi
Nice post bastrentaz claudio
jack cortese
- My post's
[url=http://chatter.perls.ddisk.com/2kpmb.html] Gulfport ms police [/url] [url=http://kalane016.perls.ddisk.com/0vczq.html] Chase bank cufflinks [/url] [url=http://niep016.maxdns.org/jjale.html] What to say sample thank you memorial notes [/url] [url=http://dernvar4512.myip.hu/5dlzy.html] Suntrust home equity loan [/url] [url=http://cert.codisk.com/ypxeq.html] Craigslist kansas city women [/url] erlend prestgard
eden valeggio
[url=http://mosdo016.maxdns.org/ogwrn.html] Jeff trudgian @maricopa.gov [/url] [url=http://chatters.perls.ddisk.com/7rfbh.html] Upskirtsexmovie [/url] [url=http://cert.codisk.com/lyixk.html] Craigslistporttownsend, wa [/url] [url=http://peipi7238.myip.hu/8fsgp.html] Que pasa si tomo 20 mg de clonazepam [/url] [url=http://fiti1720.myip.hu/vppnx.html] Free lessons how to percent change [/url]
Create an Account
Forgot your login or password?
Facebook Twitter More login options
English • Español • Deutsch • Русский…