You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Giulio Troccoli <Gi...@uk.linedata.com> on 2008/07/01 11:24:22 UTC

how to write pre-lock hook to enforce the use of --force

I have this problem I can't get my head around.

I need to enforce the locking of few files. I have set the
svn:needs-lock property and I do check whether these files are locked in
the pre-commit hook.

My problem is that I would like developers to steal the lock ONLY if
they use the --force option. In this case I would also like to send an
email to the previous lock owner to say that the lock has been stolen.

I can't seem to find how to check whether the --force option has been
used in the pre-lock hooks. Does anybody have any idea about this?

Thanks
Giulio
 
 
Linedata Services (UK) Ltd
Registered Office: Bishopsgate Court, 4-12 Norton Folgate, London, E1 6DB
Registered in England and Wales No 3027851     VAT Reg No 778499447

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

Re: how to write pre-lock hook to enforce the use of --force

Posted by Clint Lawrence <cl...@gmail.com>.
2008/7/1 Giulio Troccoli <Gi...@uk.linedata.com>:
>> > I have this problem I can't get my head around.
>> >
>> > I need to enforce the locking of few files. I have set the
>> > svn:needs-lock property and I do check whether these files are
> locked in
>> > the pre-commit hook.
>> >
>> > My problem is that I would like developers to steal the lock ONLY if
>> > they use the --force option. In this case I would also like to send
> an
>> > email to the previous lock owner to say that the lock has been
> stolen.
>>
>> Subversion will enforce that a user can't steal the lock without
> --force.
>
> Unless the pre-lock hooks says otherwise.

When I tried this the pre-lock hook gets run regardless, but if the
user doesn't pass --force, the lock won't be stolen. Even if the hook
exits with 0.

>> > I can't seem to find how to check whether the --force option has
> been
>> > used in the pre-lock hooks. Does anybody have any idea about this?
>>
>> You should be able to svnlook from within your pre-lock hook to see if
> the
>> path is already locked and then send you're email from there.
>
> If the path is already locked does not mean automatically that the lock
> will be stolen. I need to know whether the --force option has been used.

But I see that you still have a problem. During the pre-lock you've got no
way of knowing if the lock will succeed, but in the post-lock hook you've
got no way of knowing who the lock was stolen from so you can't send
an email directly that person.

Does that make sense, or have I missed something? I'm sorry, but
I don't think I've helped you solve the problem either way :)

Cheers,
Clint

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

RE: how to write pre-lock hook to enforce the use of --force

Posted by Giulio Troccoli <Gi...@uk.linedata.com>.
> > I have this problem I can't get my head around.
> >
> > I need to enforce the locking of few files. I have set the
> > svn:needs-lock property and I do check whether these files are
locked in
> > the pre-commit hook.
> >
> > My problem is that I would like developers to steal the lock ONLY if
> > they use the --force option. In this case I would also like to send
an
> > email to the previous lock owner to say that the lock has been
stolen.
> 
> Subversion will enforce that a user can't steal the lock without
--force.

Unless the pre-lock hooks says otherwise.

> 
> > I can't seem to find how to check whether the --force option has
been
> > used in the pre-lock hooks. Does anybody have any idea about this?
> 
> You should be able to svnlook from within your pre-lock hook to see if
the
> path is already locked and then send you're email from there.

If the path is already locked does not mean automatically that the lock
will be stolen. I need to know whether the --force option has been used.
 
 
Linedata Services (UK) Ltd
Registered Office: Bishopsgate Court, 4-12 Norton Folgate, London, E1 6DB
Registered in England and Wales No 3027851     VAT Reg No 778499447

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

Re: how to write pre-lock hook to enforce the use of --force

Posted by Clint Lawrence <cl...@gmail.com>.
2008/7/1 Giulio Troccoli <Gi...@uk.linedata.com>:
> I have this problem I can't get my head around.
>
> I need to enforce the locking of few files. I have set the
> svn:needs-lock property and I do check whether these files are locked in
> the pre-commit hook.
>
> My problem is that I would like developers to steal the lock ONLY if
> they use the --force option. In this case I would also like to send an
> email to the previous lock owner to say that the lock has been stolen.

Subversion will enforce that a user can't steal the lock without --force.

> I can't seem to find how to check whether the --force option has been
> used in the pre-lock hooks. Does anybody have any idea about this?

You should be able to svnlook from within your pre-lock hook to see if the
path is already locked and then send you're email from there. Unfortunately
the post-lock hook can't tell you if or who a lock was stolen from and by
that stage, it has already happened in the repository, so svnlook won't help
either.

Cheers,
Clint

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