[英]SVN lock a directory
Sorry if this is a duplicate, I didn't find the right answer still..对不起,如果这是重复的,我仍然没有找到正确的答案..
How do you lock a svn directory from command line?如何从命令行锁定 svn 目录? I need to lock a branch from checkins我需要从签到中锁定一个分支
Edit:编辑:
All of these answers I've found require the person to access the svn server.我找到的所有这些答案都需要此人访问 svn 服务器。 Thats not an option for me.那不是我的选择。 I work in a company where the source control machine is literally locked in a vault.我在一家公司工作,源代码控制机器实际上被锁在保险库中。 Gainning access to change auth rules is a process I can't work out ATM.获得更改授权规则的权限是一个我无法解决 ATM 的过程。
You can't lock a directory. 您无法锁定目录。 You can create authorization rules that will prohibit write access to directories. 您可以创建禁止对目录进行写访问的授权规则。 This is typically how this type of thing is done. 这通常是这类事情的完成方式。 You could also use a pre-commit hook but I think Subversion's authz is best. 您也可以使用预提交钩子,但我认为Subversion的authz是最好的。 Here is a link: 这是一个链接:
http://svnbook.red-bean.com/nightly/en/svn.serverconfig.pathbasedauthz.html http://svnbook.red-bean.com/nightly/en/svn.serverconfig.pathbasedauthz.html
I recently solved this by a solution inspired by http://www.noah.org/engineering/olden/svn_directory_lock.html 我最近通过http://www.noah.org/engineering/olden/svn_directory_lock.html启发的解决方案解决了这个问题。
The particular python script in that post is overkill, but I put the following in the pre-commit hook for my repsoitory: 该帖子中的特定python脚本是矫枉过正,但我将以下内容放在我的repsoitory的预提交钩子中:
#!/bin/sh
err() { echo ${1+"$@"} 1>&2; } # stderr is sent to user
REPOS="$1"
TXN="$2"
SVNLOOK=/usr/bin/svnlook
# Make sure there is a log message.
#
$SVNLOOK log -t "$TXN" "$REPOS" | grep -q "[a-zA-Z0-9]"
if [ $? -eq 1 ]
then
err "ERROR: Must enter a log message for this commit!"
exit 1
fi
# Usage: locked_dir dir [transaction_id]
locked_dir()
{
if [ -z "$2" ]; then _tid=""; else _tid="-t $2"; fi
$SVNLOOK propget $_tid "$REPOS" lock "$1" >/dev/null 2>&1
if [ $? -eq 0 ]; then echo true; else echo false; fi
}
for d in $($SVNLOOK dirs-changed -t "$TXN" "$REPOS")
do
locked_before=$(locked_dir $d)
locked_tx=$(locked_dir $d "$TXN")
if [ $locked_before = $locked_tx -a $locked_tx = true ]
then
err "ERROR: Directory $d is locked. Delete lock before you commit."
exit 1
fi
done
# All checks passed, so allow the commit.
exit 0
So now, you can simply use the "svn propset" and commit to create a "lock" property for a directory that you want to lock. 所以现在,你可以简单地使用“svn propset”并提交为你想要锁定的目录创建一个“lock”属性。
Here is an approach to lock a folder using a batch script.这是一种使用批处理脚本锁定文件夹的方法。
svn checkout DIRECTORY_TO_LOCK_SVN_URL LOCAL_DIRECTORY
Batch: iterate all files in a directory using a 'for' loop.批处理:使用“for”循环迭代目录中的所有文件。
svn lock -m LOCK_MESSAGE FILE_PATH
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.