You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by ig...@tektronix.com on 2008/01/30 16:55:02 UTC

Pre-commit Hook

Hi everyone,
 
I'm trying to write a pre-commit hook that prevents the user from
committing if the files in the transaction if they are not locked (this
is to force the users to lock the files before editing and to make sure
no one else is editing the file because most of our files are binaries).
So far I've been able to run the "svnlook lock [repository] [file path
in the repository]" command only in the command line, the problem is
that the pre-commit hook has only two parameters Repository and
Transaction. Is there a way to get a list of all the files included in a
transaction? (I am running svn on Windows)
 
Thanks in advance,
 
Ignacio

Re: Pre-commit Hook

Posted by Dave Lawrence <dl...@ad-holdings.co.uk>.
ignacio.lopez@tektronix.com wrote:
> Hi everyone,
>  
> I'm trying to write a pre-commit hook that prevents the user from 
> committing if the files in the transaction if they are not locked (this 
> is to force the users to lock the files before editing and to make sure 
> no one else is editing the file because most of our files are binaries). 
> So far I've been able to run the "svnlook lock [repository] [file path 
> in the repository]" command only in the command line, the problem is 
> that the pre-commit hook has only two parameters Repository and 
> Transaction. Is there a way to get a list of all the files included in a 
> transaction? (I am running svn on Windows)
>  
> Thanks in advance,
>  
> Ignacio

If you want to prevent users editing the file without getting the lock, 
then set the svn:needs-lock property.  As well as enforcing what your 
trying to do with a script, it also makes these files read-only in their 
working copy until they obtain the lock.


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

Re: Pre-commit Hook

Posted by annonygmouse <an...@yahoo.co.uk>.
ignacio.lopez@tektronix.com wrote:
> Hello David,
> 
> Yes, the svn:needs-lock for the client worked but I wanted to reinforce
> them by putting something in the server side as well 

Better than check if the user has the lock (using needs-lock) forces it, 
what you should do is to add any new file the "needs-lock" property (and 
obviously adding the property to all files in current repository).

Sebastià


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

RE: Re: Pre-commit Hook

Posted by ig...@tektronix.com.
Hello David,

Yes, the svn:needs-lock for the client worked but I wanted to reinforce
them by putting something in the server side as well 

Thanks,

Ignacio

-----Original Message-----
From: Bicking, David (HHoldings, IT)
[mailto:David.Bicking@thehartford.com] 
Sent: Friday, February 01, 2008 6:09 AM
To: Ryan Schmidt; Lopez, Ignacio
Cc: users@subversion.tigris.org
Subject: RE: Re: Pre-commit Hook

> -----Original Message-----
> From: Ryan Schmidt [mailto:subversion-2007b@ryandesign.com] 
> 
> On Jan 31, 2008, at 17:15, ignacio.lopez@tektronix.com wrote:
> 
> >> If you want to prevent users editing the file without getting the 
> >> lock, then set the svn:needs-lock property.  As well as enforcing 
> >> what your trying to do with a script, it also makes these files 
> >> read-only in their working copy until they obtain the lock.
> >
> >
> > Thanks all,
> >
> > I tried both procedures and finally got them working, the pre-commit
> > hook was pretty hard I have to say and it works great with existing
> > files, it requires the user to lock the files before commiting any
> > changes... BUT
> > I just tried to add new files and it wouldn't let me 
> because my "new"
> > files are not locked =|... Well they are not under revision 
> control  
> > so I
> > can not lock them. I also tried creating folders and 
> deleting files  
> > with
> > the same results...

You didn't say if the needs-lock worked for you or not.  If it worked
for you, then you can solve the problem with added files by using
auto-props.

> >
> > Is there a way to distinguish a 'delete file/folder', 'add',  
> > 'import' or
> > 'mkdir' transaction from a 'file changed' transaction?
> 
> Everything you need should be in the output of "svnlook changed".  
> Added items have an "A" at the beginning of the line, so you can  
> exclude those. Directories have a slash at the end of the line, so  
> you can exclude those.



************************************************************************
*
This communication, including attachments, is
for the exclusive use of addressee and may contain proprietary,
confidential and/or privileged information.  If you are not the intended
recipient, any use, copying, disclosure, dissemination or distribution
is
strictly prohibited.  If you are not the intended recipient, please
notify
the sender immediately by return e-mail, delete this communication and
destroy all copies.
************************************************************************
*


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


RE: Re: Pre-commit Hook

Posted by "Bicking, David (HHoldings, IT)" <Da...@thehartford.com>.
> -----Original Message-----
> From: Ryan Schmidt [mailto:subversion-2007b@ryandesign.com] 
> 
> On Jan 31, 2008, at 17:15, ignacio.lopez@tektronix.com wrote:
> 
> >> If you want to prevent users editing the file without getting the 
> >> lock, then set the svn:needs-lock property.  As well as enforcing 
> >> what your trying to do with a script, it also makes these files 
> >> read-only in their working copy until they obtain the lock.
> >
> >
> > Thanks all,
> >
> > I tried both procedures and finally got them working, the pre-commit
> > hook was pretty hard I have to say and it works great with existing
> > files, it requires the user to lock the files before commiting any
> > changes... BUT
> > I just tried to add new files and it wouldn't let me 
> because my "new"
> > files are not locked =|... Well they are not under revision 
> control  
> > so I
> > can not lock them. I also tried creating folders and 
> deleting files  
> > with
> > the same results...

You didn't say if the needs-lock worked for you or not.  If it worked
for you, then you can solve the problem with added files by using
auto-props.

> >
> > Is there a way to distinguish a 'delete file/folder', 'add',  
> > 'import' or
> > 'mkdir' transaction from a 'file changed' transaction?
> 
> Everything you need should be in the output of "svnlook changed".  
> Added items have an "A" at the beginning of the line, so you can  
> exclude those. Directories have a slash at the end of the line, so  
> you can exclude those.



*************************************************************************
This communication, including attachments, is
for the exclusive use of addressee and may contain proprietary,
confidential and/or privileged information.  If you are not the intended
recipient, any use, copying, disclosure, dissemination or distribution is
strictly prohibited.  If you are not the intended recipient, please notify
the sender immediately by return e-mail, delete this communication and
destroy all copies.
*************************************************************************


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


RE: Pre-commit Hook

Posted by ig...@tektronix.com.
That's true, I'm actually trimming that string to get the file path in
the repo...
You know, it's one of those days...

Thanks....
 

-----Original Message-----
From: Ryan Schmidt [mailto:subversion-2007b@ryandesign.com] 
Sent: Thursday, January 31, 2008 4:18 PM
To: Lopez, Ignacio
Cc: users@subversion.tigris.org
Subject: Re: Pre-commit Hook


On Jan 31, 2008, at 17:15, ignacio.lopez@tektronix.com wrote:

>> If you want to prevent users editing the file without getting the  
>> lock,
>> then set the svn:needs-lock property.  As well as enforcing what your
>> trying to do with a script, it also makes these files read-only in
>> their working copy until they obtain the lock.
>
>
> Thanks all,
>
> I tried both procedures and finally got them working, the pre-commit
> hook was pretty hard I have to say and it works great with existing
> files, it requires the user to lock the files before commiting any
> changes... BUT
> I just tried to add new files and it wouldn't let me because my "new"
> files are not locked =|... Well they are not under revision control  
> so I
> can not lock them. I also tried creating folders and deleting files  
> with
> the same results...
>
> Is there a way to distinguish a 'delete file/folder', 'add',  
> 'import' or
> 'mkdir' transaction from a 'file changed' transaction?

Everything you need should be in the output of "svnlook changed".  
Added items have an "A" at the beginning of the line, so you can  
exclude those. Directories have a slash at the end of the line, so  
you can exclude those.


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


Re: Pre-commit Hook

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Jan 31, 2008, at 17:15, ignacio.lopez@tektronix.com wrote:

>> If you want to prevent users editing the file without getting the  
>> lock,
>> then set the svn:needs-lock property.  As well as enforcing what your
>> trying to do with a script, it also makes these files read-only in
>> their working copy until they obtain the lock.
>
>
> Thanks all,
>
> I tried both procedures and finally got them working, the pre-commit
> hook was pretty hard I have to say and it works great with existing
> files, it requires the user to lock the files before commiting any
> changes... BUT
> I just tried to add new files and it wouldn't let me because my "new"
> files are not locked =|... Well they are not under revision control  
> so I
> can not lock them. I also tried creating folders and deleting files  
> with
> the same results...
>
> Is there a way to distinguish a 'delete file/folder', 'add',  
> 'import' or
> 'mkdir' transaction from a 'file changed' transaction?

Everything you need should be in the output of "svnlook changed".  
Added items have an "A" at the beginning of the line, so you can  
exclude those. Directories have a slash at the end of the line, so  
you can exclude those.


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

RE: Pre-commit Hook

Posted by ig...@tektronix.com.
>If you want to prevent users editing the file without getting the lock,

>then set the svn:needs-lock property.  As well as enforcing what your 
>trying to do with a script, it also makes these files read-only in
their 
>working copy until they obtain the lock.

Thanks all,

I tried both procedures and finally got them working, the pre-commit
hook was pretty hard I have to say and it works great with existing
files, it requires the user to lock the files before commiting any
changes... BUT
I just tried to add new files and it wouldn't let me because my "new"
files are not locked =|... Well they are not under revision control so I
can not lock them. I also tried creating folders and deleting files with
the same results...

Is there a way to distinguish a 'delete file/folder', 'add', 'import' or
'mkdir' transaction from a 'file changed' transaction?

Thanks in advance for your help,

Ignacio
 

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


RE: Pre-commit Hook

Posted by "Reedick, Andrew" <jr...@ATT.COM>.
> From: ignacio.lopez@tektronix.com [mailto:ignacio.lopez@tektronix.com] 
> Sent: Wednesday, January 30, 2008 11:55 AM
> To: users@subversion.tigris.org
> Subject: Pre-commit Hook

> I'm trying to write a pre-commit hook that prevents the user from 
> committing if the files in the transaction if they are not locked 
> (this is to force the users to lock the files before editing and 
> to make sure no one else is editing the file because most of our 
> files are binaries). So far I've been able to run the "svnlook 
> lock [repository] [file path in the repository]" command only in 
> the command line, the problem is that the pre-commit hook has 
> only two parameters Repository and Transaction. Is there a way to
>  get a list of all the files included in a transaction? (I am 
> running svn on Windows)
 


Use the 'svnlook' commands to see what files are in the transaction.  (Specifically 'svnlook changed')
	http://svnbook.red-bean.com/en/1.4/index.html

Search on 'svnlook subcommands' to find the relevant sections.


*****

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA623



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