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

Re: Preprocess files before checking for modifications

From: Stefan Hett <stefan_at_egosoft.com>
Date: Mon, 8 Aug 2016 17:22:19 +0200

On 8/8/2016 3:59 PM, Volker Drewer-Gutland wrote:
> Hi,
>
> the repository files of my projects consist mainly of xml files.
> The xml files are generated by different xml parsers which causes slight differences in the xml structure of the files (order of attributes, single quotes instead of double quotes in headers, etc), depending on which parser processes the same file, e.g. parser 1 places attributes like this <elem a="a" b="b"/> and parser 2 places attributes like this <elem b="b" a="a">. Obviously svn sees this as a file modification which does not matter for my purposes.
> My question now is if there is a possibility to pre-process the contents of a specific file type before it is passed on to svn when the commit dialog is called so I can "normalize" the xml files before they are compared?
>
> Regards
>
> Volker
>
>
One way to handle this could be to add a pre-commit hook which checks
the xml format for validity (aka: whether it's using the format you
want) and reject the commit, if the validation fails. You could then
correct the files before the commit (aka: adjust/correct the parser).

If that's not possible, another approach might be to perform a second
file sanitizing in the post-commit hook. Aka:
- commit the file
- the post commit hook performs a validation of the file and normalizes it
- the server then puts the normalized file its own (separate) working
copy and commits the change then automatically
The downside of this approach would be that all xml commits will
consiste of two separate commits now and the WC where the initial commit
was done from is always out of date after the commit and requires an
update afterwards to bring the file up to date with HEAD again.

As far as I do remember modifications done to the file in the pre-commit
hook is not supported (or at least not advertised?), since the client
which sent the commit expects the content to be accepted as is in the
repository. Aka: it doesn't query the content which was transmitted to
the repository and hence, if the content would have been altered in the
pre-commit hook, the client would have an incorrect representation of
the server state.

-- 
Regards,
Stefan Hett
------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=3181634
To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_tortoisesvn.tigris.org].
Received on 2016-08-08 17:22:31 CEST

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

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