On Sep 29, 2006, at 12:57, Don Caprio wrote:
> I'm new to subversion so I appoligize in advance for any stupid
> newbie questions.
>
> I'd like to restrict my users from creating top-level directories.
> After looking through the docs and FAQ's it appears that the best
> way would be to create a pre-commit hook. Am I on the right path or
> is there a better way? The Apache mod_dav_svn module would fit the
> bill but clients will be using command-line.
The method by which the repository is served (apache mod_dav_svn,
svnserve, svn+ssh, direct file access) has little to do with the
client used to access it (command-line client, TortoiseSVN, WebSVN,
Trac, SmartSVN, etc.). In other words, you can certainly serve a
repository with mod_dav_svn and access it with the command-line svn
client.
The question then is: what feature of mod_dav_svn do you think will
help you in this scenario? I think there are ways to make this work
regardless of how you serve the repository.
Yes, a pre-commit script sounds like the right way to approach this
problem:
> I've done some poking around with the pre-commit script however I'm
> having some trouble figuring it all out.
>
> The command 'svn mkdir file:///repos/projectA -m "make initial
> project dir"
> generates the following hook variables:
>
> ***START pre-commit script. TXN=y REPOS=/repos
> author: caprio
> changed: A projectA/
> dirs-changed: /
> proplist:
> propget:
> ***END pre-commit script
>
> If dirs-changed = "/" and changed: = "A" would I be correct in
> interpreting that user wishes to create 'projectA' in the repos
> root dir?
The way it's implemented internally is that adding a file or
directory (any item) to a repository means that its containing
directory gets modified. So, the directory getting modified is "/"
and the modification being made is that the directory "projectA" is
being added to it. You know it's being added because the line says
"A projectA/" -- "A" means "added", "projectA" is of course the
name of the item being added, and the "/" at the end of "projectA"
tells you it's a directory.
So if you want to prevent directories from being added to the root,
run "svnlook dirs-changed" as you do, and if it's "/", then run
"svnlook changed", and if any line starts with "A" and ends with "/"
then you exit the hook with a nonzero status and print an appropriate
error message to inform the user.
If you want to prevent both files and directories from being added to
"/" then just search for lines output from "svnlook changed" starting
with "A".
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Mon Oct 2 00:14:14 2006