问题
We are currently using SVN in the checkout-modify-merge mechanism and instead I want to re-configure the SVN server so that we change this to lock-modify-unlock mechanism. We use Tortoise SVN client and I saw that it is possible to individually change the property of single files to enforce the "needs-lock" property but this is too laborious and instead I am looking at some way through which we can change something on the svn server side that causes all the files to apply the "needs-lock" property. Thanks for the help !
回答1:
Read Automatically add svn:needs-lock
Since you use Tortoise SVN you should especially read the part about tsvn:autoprops.
回答2:
On the server side you can't change a thing like this. What would be possible to prevent people from checking in files which don't have the property (svn:needs-lock) set...via Hook script. But that's not a recommended way to work with SVN.
回答3:
The best option is to enforce all committed files to have the svn:needs-lock property. There are several links on how to do this.
Here are some handy scripts and hooks for windows.
For unix, here is a variant of http://www.codenition.com/shell-script-to-enforce-svnneeds-lock that actually works (exit 1 in a forked while loop does not behave as expected).
Add the following code to /path/to/repo/hooks/pre-commit
# Make sure every file has the svn:needs-lock property set
while read REPOS_PATH
do
if [[ "$REPOS_PATH" =~ "^(A|M|U)[[:blank:]]{3}(.*)" ]]; then
if [ ${#BASH_REMATCH[*]} -ge 2 ]; then
if [ -z "`$SVNLOOK propget -t \"$TXN\" \"$REPOS\" svn:needs-lock \"${BASH_REMATCH[2]}\"`" ]; then
STATUS="1"
echo "$REPOS_PATH must have the svn:needs-lock property set">&2
exit 1
fi
fi
fi
done <<< "`$SVNLOOK changed -t "$TXN" "$REPOS"`"
来源:https://stackoverflow.com/questions/3749067/settings-a-svn-server-so-as-to-enable-lock-modify-unlock-mechanism-of-version-co