[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: Altering source file contents with hooks

From: Peter N. Lundblad <peter_at_famlundblad.se>
Date: 2005-03-08 08:45:37 CET

On Tue, 8 Mar 2005, HAND,Nathan wrote:

> -----Original Message-----
> From: Eric Thomas [mailto:eric@psteering.com]
> > I'm curious - is there a way, using any of the Subversion
> pre-/post-/start-commit hooks,
> > to alter the actual contents of a source file before it's committed?
> For example, we might
> > want to add a commented copyright notice to every source file, or run
> every file through a
> > "pretty-printer" program to standardize formatting.
> The subversion server doesn't have access to the source file. It only
> receives deltas. So it's simply not possible. Consider the common case
> where the subversion server is across a network.
Ofcourse it has access to the file in the repository. the problem for
modifying a transaction in a pre-commit hook is, however, that the working
copy would become out of sync and there is no way to tell the WC that
changes have happend on the server.

> The solution in this case it to create a wrapper script for svn. Call it
> "svn-that-modifies-files". Make changes to your source files in that
> script and then call the real svn.
Yes, and then you can enforce it in a pre-commit hook. Check that the
contents are valid and if not reject the commit by returning non-zero from
the script. Nte that writing to stderr in the scrit will give the user
some feedback to why the commit was rejected.


To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Tue Mar 8 08:45:20 2005

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.