How to add Comment to the file which being committed in pre-commit hook script

satheesh
satheesh
Hi All,    Am using SVN 1.7.6 & Tortoise SVN 1.7.8 client in my windows machine.    i need to add commit comments to the file(Beginning of the file) which being committed in pre-commit hook script.    Is it possible ???    Thanks

Last updated

Mand
Mand
Hi there,    There are a couple of good examples of basic pre-commit hooks here.
andyl
andyl
satheesh;121258i need to add commit comments to the file(Beginning of the file) which being committed in pre-commit hook script.  Is it possible ???
Don't. Just don't. You don't "need" to - you have a misguided want to.  First, modifying the contents of an incoming commit is a really bad idea. When a user commits a change they should have confident that what they are committing is what actually get committed. By doing what you suggest, that confidence is lost. Further, if you were to do this, the committing user's working copy would become immediately invalidated - their contents would not match the contents of that same revision in the repository.  Even worse, what if your script gets confused and modifies important parts of the file being committed, thus breaking your code completely? Or what if the script fails mid-stream, corrupting the file being committed?  Second, the Subversion developers have been asked for this feature enough times (it's analogous to CVS's $Log$ keyword) that they wrote an FAQ entry explaining why they'll never do it. Read that and take heed.
satheesh
satheesh
Thanks Mand & andyl,  but I need to add(edit) commit comments to file for certain checkin operation for some users(who have administrator privilege)only not all clients.   So it is possible to modify the file which being committed in pre-commit script, right???  I have used svnlook.exe to fetch Commit comment.   svnlook.exe log -t %TXN% %REPOS% in pre-commit.bat  Is any script is available for editing the file before it getting committed(in pre-commit itself i need to modify the file)???  Thanks in advance.
andyl
andyl
satheesh;121271but I need to add(edit) commit comments to file for certain checkin operation for some users(who have administrator privilege)only not all clients. [/quote]You'll have to explain this more clearly, because this really makes no sense to me. There should be no reason for you to have to modify an in-flight transaction. Period. Nothing you have stated here clearly explains what problem you're attempting to solve.    [QUOTE=satheesh;121271]So it is possible to modify the file which being committed in pre-commit script, right???    I have used svnlook.exe to fetch Commit comment.     svnlook.exe log -t %TXN% %REPOS% in pre-commit.bat    Is any script is available for editing the file before it getting committed(in pre-commit itself i need to modify the file)???
IIRC, you have to modify the data coming into the transaction, or allow it to go through and then immediately perform a second commit which then adds the log message.    There is a reason why there's very little information about how to do it.
satheesh
satheesh
Thanks,  Can i change the custom property in pre-commit hook, any script available???
andyl
andyl
satheesh;121333Thanks,    Can i change the custom property in pre-commit hook, any script available???
   If you do that, you're still changing the transaction in-flight, which I've now posted three times is a bad idea.
satheesh
satheesh
Is it possible in post-commit ???
andyl
andyl
satheesh;121354Is it possible in post-commit ???
   Yes, but you are now faced with:    1) Having to maintain a working copy on the server  2) The committer's WC will still be immediately out of date  3) This will slow down your workflow (as the client will wait for post-commit to finish)  4) If not done carefully, it'll recurse and you'll hose your server.    Even in post-commit, this is a bad idea and you shouldn't be doing it.
satheesh
satheesh
Thanks andyl,  there is two lines in pre-commit.temp  *** NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT *** *** FOR REVISION PROPERTIES (like svn:log or svn:author). ***  what it means ??? it is for client ???
andyl
andyl
satheesh;121356Thanks andyl,    there is two lines in pre-commit.temp    *** NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT ***  *** FOR REVISION PROPERTIES (like svn:log or svn:author). ***    what it means ??? it is for client ???
   It means exactly what I've been saying all along here. Don't change transactions in hook scripts.

1-12 of 12

Reply to this discussion

You cannot edit posts or make replies: You should be logged in before you can post.