如何創建一個顛覆服務器鉤子腳本,以防止人們提交更改(如果他們沒有先擁有該文件上的鎖定)?有關顛覆(svn)鉤子腳本的幫助
Svn服務器在Windows上。
謝謝。
P.S.在這個問題上的其他信息
Subversion (svn + tortoiseSvn) commit not locked file
如何創建一個顛覆服務器鉤子腳本,以防止人們提交更改(如果他們沒有先擁有該文件上的鎖定)?有關顛覆(svn)鉤子腳本的幫助
Svn服務器在Windows上。
謝謝。
P.S.在這個問題上的其他信息
Subversion (svn + tortoiseSvn) commit not locked file
使用預先提交鉤子。 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:未鎖定需要鎖定的文件。
要確定此修改的路徑承諾:
svnlook changed $1 --transaction $2
循環遍歷文件(如$PATH
循環項目)在「改變」和確定的svn:需要鎖,如果他們目前鎖定:
svnlook propget $REPOS-PATH svn:needs-lock $PATH
svnlook lock $1 $PATH
編寫一個stderr並在需要時返回非零來終止此提交。
用於顯示pre-commit +屬性邏輯的組合 – 2009-12-18 00:23:18
實際上svnlook propget看起來像這樣: svnlook propget $ REPO_PATH propname $ FILE_PATH – 2009-12-23 01:09:45
您可以使用<your repos directory>/hooks/pre-commit
並使用一些批處理腳本(甚至是一個完全成熟的方案,只要它的可執行文件會被罰款)。如果它返回提交將會成功;否則會失敗。
查看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.
屬於serverfault.com – Gonzalo 2009-12-18 00:07:02
是不是一個文件上鎖的整個點,是這樣的,所以別人不能提交更改該文件? – jaywon 2009-12-18 00:07:52
@jaywon:文件沒有被任何人鎖定。我認爲它有svn:needs-lock set(因爲我看到這個問題來自於前一個問題)。 @Irfan:糾正我,如果我錯了,但你試圖拒絕提交svn:需要鎖定文件沒有被鎖定的權利? – 2009-12-18 00:14:09