2

最初にファイルのロックを所有していない場合に変更をコミットできないようにするSubversionサーバーフックスクリプトを作成するにはどうすればよいですか?

SvnサーバーはWindows上にあります。

ありがとう。

PSこの質問の追加情報

Subversion(svn + tortoiseSvn)コミットはロックされていないファイル

4

2 に答える 2

4

事前コミットフックを使用します。Pre-commitフックは2つの引数を受け取ります。

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

svnlookロックされていないsvn:needs-lockファイルがあるかどうかを判断するためにを使用する必要があります。

このコミットによって変更されたパスを判別するには、次のようにします。

svnlook changed $1 --transaction $2

'changed'のファイルを($PATHループアイテムとして)ループし、svn:needs-lockを判別し、それらが現在ロックされているかどうかを確認します。

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

stderrに書き込み、ゼロ以外を返し、必要に応じてこのコミットを中止します。

于 2009-12-18T00:20:18.757 に答える
1

いくつかのバッチスクリプトを使用して使用でき<your repos directory>/hooks/pre-commitます(または、実行可能である限り、完全なプログラムでも問題ありません)。0が返された場合、コミットは成功します。そうしないと失敗します。

post-lock.tmpl例については、同じディレクトリを参照してください。

# 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.
于 2009-12-18T00:08:40.027 に答える