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

Re: Beautify code thru a hook

From: <pwd_at_mdtsoft.com>
Date: 2003-05-09 15:29:03 CEST

On 9 May, Ben Collins-Sussman wrote:
> "Jean-Luc Wasmer" <jl.subversion@wasmer.ca> writes:
>
>> How can I filter committed files thru a code beautifier (like astyle)?
>
> I'm going to pretend for a moment that this idea doesn't make me
> cringe. :-)
>
> In theory, you'd write a pre-commit hook script which examines the
> pending commit transaction in the repository, and changes it. You'd
> probably have to use the svn_fs.h API to directly tweak the
> transaction, either via C or Python.
>
> But in practice, the svn client can't deal with this sort of thing.
> If the pre-commit hook changes file contents, the client currently has
> no way of learning about this. The server simply says "commit
> complete", and the client then goes on assuming that the files
> committed from the original working-copy directory are identical to
> the ones in the repository. This will cause detrimental things; 'svn
> up' and other functions will start to produce nasty checksum errors,
> and the original working-copy directory will slowly bitrot.
>
>

I have been thinking about this; my current design is to have a thing that
will be kicked off by cron, say about once per day, that will do the following

1) in its working directory (it will have one that will not be used by any
        real user) do a "svn update" noting what files are chnaged. (I want
        to do this with the perl bindings but I have not had time to work on
        those for a while yet).

2) for each file that has changes process it (beautifier, check for proper
        copyrights, whatever).

3) issue a "svn commit" with a comment that says that this has been a automatic
        update.

The advantages of this are that all of the automatic changes will be look just
        like they where done by a person. (abit one who works real late :-) )
The disadvantage is that for a while bad data is in in the store.

After this has been running for a while then put in a pre-commit hook that prevents
checkin if any of the checks fail (with a message to the user as to why the commit
was not accecpted and how to fix it).

-- 
It is MDT, Inc's policy to delete mail containing unsolicited file attachments.
Please be sure to contact the MDT staff member BEFORE sending an e-mail with
any file attachments; they will be able to arrange for the files to be received.
This email, and any files transmitted with it, is confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error, please advise postmaster@mdtsoft.com
<mailto:postmaster@mdtsoft.com>.
Philip W. Dalrymple III <pwd@mdtsoft.com>
MDT Software - The Change Management Company
+1 678 297 1001
Fax +1 678 297 1003
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri May 9 15:58:56 2003

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

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