Help with subversion (svn) hook script

How to create a subversion script server hook that prevents people from making changes if they don't first have a lock in the file?

Svn server is in windows.

Thanks.

PS Additional information in this matter

Subversion (svn + tortoiseSvn) commit not locked file

+2
source share
2 answers

Use the pre-hook. Pre-commit capture takes 2 arguments:

# [1] REPOS-PATH (the path to this repository) # [2] TXN-NAME (the name of the txn about to be committed) 

You need to use svnlook to determine if there are svn: needs-lock files that are not locked.

To determine the paths changed by this commit:

 svnlook changed $1 --transaction $2 

Scroll the files ( $PATH as a loop element) to 'changed' and define svn: require-lock, and if they are currently locked:

 svnlook propget $REPOS-PATH svn:needs-lock $PATH svnlook lock $1 $PATH 

Write to stderr and return a nonzero value to abort this commit if necessary.

+4
source

You can use <your repos directory>/hooks/pre-commit and use some batch scripting (or even a full-blown program, if it is executed, it will be fine). If it returns 0 , the commit will succeed; otherwise it will not work.

See post-lock.tmpl in the same directory for an example.

 # PRE-COMMIT HOOK # # The pre-commit hook is invoked before a Subversion txn is # committed. Subversion runs this hook by invoking a program # (script, executable, binary, etc.) named 'pre-commit' (for which # this file is a template), with the following ordered arguments: # # [1] REPOS-PATH (the path to this repository) # [2] TXN-NAME (the name of the txn about to be committed) # # The default working directory for the invocation is undefined, so # the program should set one explicitly if it cares. # # If the hook program exits with success, the txn is committed; but # if it exits with failure (non-zero), the txn is aborted, no commit # takes place, and STDERR is returned to the client. The hook # program can use the 'svnlook' utility to help it examine the txn. # # On a Unix system, the normal procedure is to have 'pre-commit' # invoke other programs to do the real work, though it may do the # work itself too. 
+1
source

All Articles