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

Re: hook scripts: only commit if locked

From: si <sshnug.si_at_gmail.com>
Date: 2005-11-03 13:09:56 CET

> What I really want, is the ability to enforce the following rule:
> A user can only commit changes to a needs-lock file if he/she has locked
> that file.
> Is it possible, with some configuration or hook scripts?

Sure, the pre-commit hook combined with calls to svnlook.

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

First thing i'd do is see if the svn:needs-lock property is set on
any of the files in the transaction, do this using 'svnlook proplist'.
If there are none, then pass that part of your pre-commit hook.

If you do find svn:needs-lock, find the transaction author:
http://svnbook.red-bean.com/nightly/en/svn.ref.svnlook.c.author.html

Then iterate through each file in the transction (in case they have
different lock owners), 'svnlook changed' gets your list of files.

On each file you call 'svnlook propget [repos] svn:needs-lock [path/to/file]',
and when found, call 'svnlook lock [repos] [path/to/file]' to validate the lock
owner against the transaction author.

Hmmm...that seems a fairly heavy-handed approach, but i'm unsure how
you can (easilly) list all the locks (and their owners) from a transaction?

Personally i'd probably just use locks as per normal, and try to educate
users not to modify read-only files :) You can always revert back to a
previous revision if they break the rules.

peace
si

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu Nov 3 13:12:12 2005

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

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