You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by "MALCOR, Claire" <cl...@astrium.eads.net> on 2006/07/07 14:22:22 UTC

RE : RE : How to modify a meta-data in pre-commit hook

Thanks for your reply.

Is there any solution to do this without using hook script? 


-----Original Message-----
From: Ryan Schmidt [mailto:subversion-2006c@ryandesign.com] 
Sent: Friday, July 07, 2006 3:56 PM
To: MALCOR, Claire
Cc: 'users@subversion.tigris.org'
Subject: Re: RE : How to modify a meta-data in pre-commit hook



On Jul 7, 2006, at 15:23, MALCOR, Claire wrote:

>> What meta-data are you trying to modify? Are you talking about 
>> revision properties, like svn:author, svn:date, svn:log, etc.? If so, 
>> that's fine, but you must not attempt to modify file contents or 
>> versioned properties like svn:eol-style or svn:mime-type because the 
>> working copy would then be out of sync with the repository and the wc 
>> would most likely break in mysterious ways.
>
>> What does it mean when you say the committed file is locked by the 
>> commit action? Where is it locked? Are you talking about a Subversion 
>> lock, or something else?
>
>
> I have set a property named 'FM' on all my directories and files,
> with the command "svn propset 'FM' 'blabla' files". And it is this  
> property that I wish to modify in the pre-commit hook.
> When I try to do it, I have always the error : "The working copy is  
> locked"

Ok. Don't do that. :-) If they're properties on files (which are  
versioned, as opposed to properties on revisions, which are not),  
then you should not be touching them in your pre-commit hook. I don't  
know why you would be getting a message that the working copy is  
locked, but I'm also disinclined to investigate further, since what  
you're trying to do is not recommended and will land you in trouble  
later. Please see the warning at the end of this page of the book:

http://svnbook.red-bean.com/en/1.2/ 
svn.reposadmin.create.html#svn.reposadmin.create.hooks

> Do not attempt to modify the transaction using hook scripts. A
> common example of this would be to automatically set properties  
> such as svn:eol-style or svn:mime-type during the commit. While  
> this might seem like a good idea, it causes problems. The main  
> problem is that the client does not know about the change made by  
> the hook script, and there is no way to inform the client that it  
> is out-of-date. This inconsistency can lead to surprising and  
> unexpected behavior.
>
> Instead of attempting to modify the transaction, it is much better
> to check the transaction in the pre-commit hook and reject the  
> commit if it does not meet the desired requirements.

---------------------------------------------------------

CE COURRIER ELECTRONIQUE EST A USAGE STRICTEMENT INFORMATIF ET NE SAURAIT ENGAGER DE QUELQUE MANIERE QUE CE SOIT EADS ASTRIUM SAS, NI SES FILIALES.

SI UNE ERREUR DE TRANSMISSION OU UNE ADRESSE ERRONEE A MAL DIRIGE CE COURRIER, MERCI D'EN INFORMER L'EXPEDITEUR EN LUI FAISANT UNE REPONSE PAR COURRIER ELECTRONIQUE DES RECEPTION. SI VOUS N'ETES PAS LE DESTINATAIRE DE CE COURRIER, VOUS NE DEVEZ PAS L'UTILISER, LE CONSERVER, EN FAIRE ETAT, LE DISTRIBUER, LE COPIER, L'IMPRIMER OU EN REVELER LE CONTENU A UNE TIERCE PARTIE.



This email is for information only and will not bind EADS Astrium SAS in any contract or obligation, nor its subsidiaries.

If you have received it in error, please notify the sender by return email. If you are not the addressee of this email, you must not use, keep, disseminate, copy, print or otherwise deal with it.

---------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: How to modify a meta-data in pre-commit hook

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Jul 7, 2006, at 16:22, MALCOR, Claire wrote:

>> On Jul 7, 2006, at 15:23, MALCOR, Claire wrote:
>>
>>> I have set a property named 'FM' on all my directories and files,
>>> with the command "svn propset 'FM' 'blabla' files". And it is this
>>> property that I wish to modify in the pre-commit hook.
>>> When I try to do it, I have always the error : "The working copy is
>>> locked"
>>
>> Ok. Don't do that. :-) If they're properties on files (which are
>> versioned, as opposed to properties on revisions, which are not),
>> then you should not be touching them in your pre-commit hook. I don't
>> know why you would be getting a message that the working copy is
>> locked, but I'm also disinclined to investigate further, since what
>> you're trying to do is not recommended and will land you in trouble
>> later. Please see the warning at the end of this page of the book:
>>
>> http://svnbook.red-bean.com/en/1.2/
>> svn.reposadmin.create.html#svn.reposadmin.create.hooks
>>
>>> Do not attempt to modify the transaction using hook scripts. A
>>> common example of this would be to automatically set properties
>>> such as svn:eol-style or svn:mime-type during the commit. While
>>> this might seem like a good idea, it causes problems. The main
>>> problem is that the client does not know about the change made by
>>> the hook script, and there is no way to inform the client that it
>>> is out-of-date. This inconsistency can lead to surprising and
>>> unexpected behavior.
>>>
>>> Instead of attempting to modify the transaction, it is much better
>>> to check the transaction in the pre-commit hook and reject the
>>> commit if it does not meet the desired requirements.
>
> Is there any solution to do this without using hook script?

I think the recommended solution is:

Install a pre-commit hook that prevents people from committing files  
unless they have the FM property. If the FM property is missing on  
any file, print out an error message advising the user to add the  
property to that file before committing.

Your committers would quickly become annoyed with this if they had to  
do this manually every time, which is why your committers should set  
up local client config files in which the auto-props feature is used  
to automatically apply the FM property to new files. The error  
message your pre-commit hook prints can also advise users how they  
could set this up, or even point them at a URL where they can  
download a ready-made config file.

If you already have files in your repository that do not have this  
property, and you now want them to, there are also scripts that will  
go and do this for you automatically.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org