tags:

views:

663

answers:

3
+3  Q: 

Subversion Hook

I am working in a project where there are configuration files, one in number for each of the environments where the application would be deployed.

When a developer modifies one of these files, the developer should not be allowed to check-in the file individually, but check-in all the files together or at least the developer should be informed that this needs to be done.

How can we achieve it?

+5  A: 

I would think you could write a pre-commit hook to do this - just have a list of files where if one is committed then they must all be committed.

You can write hooks in any language that you can write a command-line application in. The only gotcha is that they run in the context of the SVN server, and (at least traditionally, I don't know if this is improved), they aren't given much environment when they start - you can be caught out be a lack of 'PATH' for example.

Your repository will have example batchfile/shell-script hooks in the 'hooks' directory, but I've also written them in C# in the past.

This http://wordaligned.org/articles/a-subversion-pre-commit-hook looks like a good general introduction to pre-commit hooks.

Will Dean
A: 

When you say that it needs to be run in the context of the SVN server, do you say that the working copy needs to necessarily be in the same physical server?

Shyam
Danny has answered this nicely. Forget about the working copy, this is entirely repository/server stuff.
Will Dean
+1  A: 

No, To get information about the transaction your script can simply query svn about the details. And svn can provide that information, it need not be on the same server.

What he means is that when subversion executes your hook it runs w/o an environment and by the svn server itself. Any external resources your svn hook might need have to be accessible by the svn server account. From what you are asking this may not be a problem, assuming you don't need some sort of external database access or the like for you to compare the transaction against.

Your best bet is to look at some of the subversion hooks that come with svn for examples. Also SVN Hook Arguments lists how each hook is called.

Danny