tags:

views:

108

answers:

3

Here's the dilemma:

I have a folder structure:

product/branches/stable product/branches/someotherbranch product/tags product/trunk

I have two users: John and Joe.

I want to prevent Joe from committing to: product/branches/stable and product/tags

What is the pre-commit hook syntax in Perl or Bash or whatever to get the job done?

+2  A: 

Why don't you use access limitations? Edit your authz file:

[/product/branches/stable product/]
Joe = r
John = rw

It is much easier and less error prone(eg restructuring your repo layout)

Peter Parker
Cool, but, I'd prefer to do this in a pre-commit hook if possible.
randy melder
@randy - Why? What does a pre-commit hook buy you that this does not?
retracile
I've got 100's of folders in real life. It requires too much explanation here, but basically, I need to say "if a folder contains some-word, only allow user joe and jane to commit" - however, the folders are added and removed frequently. We have an established naming convention and do NOT have free access to the server since it's in a production environment managed by an IT group. Access requires bureaucracy and red tape. So we're stuck with pattern matching for changing folder structures and users. I figured this would be a common problem for an SCM in a large swdev shop.
randy melder
By 'free access' I mean shell / SSH access.
randy melder
A: 

You can also consider integrating your repo with LDAP and use permissions to control access

mfeingold
A: 

The pre-commit hook script is called with two arguments that you can use with svnlook to get more details on the transaction about to be performed.

For example, if %1 and %2 are your hook script arguments,

svnlook author %1 -t %2

gives the author, and

svnlook dirs-changed %1 -t %2

gives all the directories involved. There are other commands of course, as you can see in the SVN online book.

RedGlyph