svnrepositorycommitvisualsvn-server

Changing files on repository after commit


I have a history.txt file in my repository. I would like to fill this history.txt file with some information that are generated automatically after a commit happens (or before?).

I am using TortoiseSVN and the repository is located on a VisualSVN server.

I was thinking to use a pre/post-commit hook, but i think this wont work out like SVNbook says:

While hook scripts can do almost anything, there is one dimension in which hook script authors should show restraint: do not modify a commit transaction using hook scripts. While it might be tempting to use hook scripts to automatically correct errors, shortcomings, or policy violations present in the files being committed, doing so can cause problems. Subversion keeps client-side caches of certain bits of repository data, and if you change a commit transaction in this way, those caches become indetectably stale. This inconsistency can lead to surprising and unexpected behavior. Instead of modifying the transaction, you should simply validate the transaction in the pre-commit hook and reject the commit if it does not meet the desired requirements. As a bonus, your users will learn the value of careful, compliance-minded work habits.

Is there a way to modify a files on a repository automatically? Or do you have other suggestions? Or is there maybe something like a script on client side, which makes changes before committing?

Thanks for your help!


Solution

  • You need to modify the file on the client-side and then commit the change. You can write a script and use the SVN command-line client commands. Here is an example:

    1. Run the svn checkout command to get a working copy from your repository that contains the history.txt file.
    2. Write and run a script that modifies the history.txt file and runs the svn commit command. You also need to run svn update before you modify the file and commit.

    PS Deploying a CI or build machine as @driverzero suggested can be an overkill if your task is only to automatically update one file via a script.