还在苦苦敲代码开发APP?你out啦! 试试积木搭建APP吧~

SVN needs-lock 设置强制只读属性(官方资料)

来源:清泛原创     2016-06-27 16:05:08    人气:     我有话说( 0 人参与)

Automatic lock-modify-unlockFrom SubversionWikiJump to: navigation, searchDifferent versions of binary files cannot be...

Automatic lock-modify-unlock


From SubversionWiki

Jump to: navigation, search

Different versions of binary files cannot be merged. Therefore versioning of binary files should follow the lock-modify-unlock model[1]. This setup uses the following three measures

forces users to use property svn:needs-lock on newly added binary files. Denies commits when the property is not available 

sets the svn:needs-lock property on all already existing binary files in repositories 

configures users to automatically set property svn:needs-lock on newly added binary files

1) - create a pre-commit.cmd script in the repository\hooks directory. This script verifies that property svn:needs-lock is set on binary files and denies the commit if the property is not available (Windows only):

@echo off

set REPOS=%1

set TRANSACTION=%2

set SVNLOOK="c:\Program Files\Subversion\apache2.2\bin\svnlook.exe"

set TEMP=c:\temp
if exist %TEMP%\tempfile%2 del %TEMP%\tempfile%2

for /f "tokens=1,2 usebackq" %%i in (`%SVNLOOK% changed -t %2 %1`) do @if %%i==A @echo %%j >> %TEMP%\tempfile%2

if not exist %TEMP%\tempfile%2 goto NOFILESADDED

for /f "usebackq" %%i in (`findstr /E /I /R "\.bmp.$ \.gif.$ \.ico.$ \.jpeg.$ \.jpg.$ \.png.$ \.tif.$ \.tiff.$ \.doc.$ \.jar.$ \.odt.$ \.pdf.$ \.ppt.$ \.swf.$ \.vsd.$ \.xls.$ \.zip.[        DISCUZ_CODE_0        ]quot; %TEMP%\tempfile%2`) do (

%SVNLOOK% propget -t %2 %1 svn:needs-lock %%i 1> nul 2> nul

if ERRORLEVEL 1 (

echo commit denied, binary files must have property svn:needs-lock >&2

type %TEMP%\tempfile%2 >&2

del %TEMP%\tempfile%2

EXIT /B 1

)

)

del %TEMP%\tempfile%2

:NOFILESADDED

EXIT /B 0

2) Recursively set svn:needs-lock property on binaries

If you need to apply svn:needs-lock on already existing binaries in a repository, do the following on a client (not on the svn server): - checkout a repository - add to following line to a cmd script (Windows only):

FOR /R c:\full\path\to\repository %%v in (*.bmp *.gif *.ico *.jpeg *.jpg *.png *.tif *.tiff *.doc *.jar *.odc *.odf *.odg *.odi *.odp *.ods *.odt *.pdf *.ppt *.ser *.swf *.vsd *.xls *.zip) do svn propset svn:needs-lock yes %%~fv

- run the script

 

3) Configure users to automatically use svn:needs-lock property on new binary files

New binary files should have the svn:needs-lock property set, this is verified by the script of step 1. This can be achieved automatically if users configure their svn client config file.

- under windows the SVN config file is "C:\Documents and Settings\[USER_NAME]\Application Data\Subversion\config"

Replace or merge the [miscellany] and [auto-props] sections in the svn config file with the following:

[miscellany]

enable-auto-props = yes
[auto-props]

### The format of the entries is:

###   file-name-pattern = propname[=value][;propname[=value]...]

### The file-name-pattern can contain wildcards (such as '*' and

### '?').  All entries which match will be applied to the file.

### Note that auto-props functionality must be enabled, which

### is typically done by setting the 'enable-auto-props' option.

*.bmp = svn:mime-type=image/bmp;svn:needs-lock=*

*.gif = svn:mime-type=image/gif;svn:needs-lock=*

*.ico = svn:mime-type=image/x-icon;svn:needs-lock=*

*.jpeg = svn:mime-type=image/jpeg;svn:needs-lock=*

*.jpg = svn:mime-type=image/jpeg;svn:needs-lock=*

*.png = svn:mime-type=image/png;svn:needs-lock=*

*.tif = svn:mime-type=image/tiff;svn:needs-lock=*

*.tiff = svn:mime-type=image/tiff;svn:needs-lock=*
*.doc = svn:mime-type=application/msword;svn:needs-lock=*

*.jar = svn:mime-type=application/octet-stream;svn:needs-lock=*

*.odc = svn:mime-type=application/vnd.oasis.opendocument.chart;svn:needs-lock=*

*.odf = svn:mime-type=application/vnd.oasis.opendocument.formula;svn:needs-lock=*

*.odg = svn:mime-type=application/vnd.oasis.opendocument.graphics;svn:needs-lock=*

*.odi = svn:mime-type=application/vnd.oasis.opendocument.image;svn:needs-lock=*

*.odp = svn:mime-type=application/vnd.oasis.opendocument.presentation;svn:needs-lock=*

*.ods = svn:mime-type=application/vnd.oasis.opendocument.spreadsheet;svn:needs-lock=*

*.odt = svn:mime-type=application/vnd.oasis.opendocument.text;svn:needs-lock=*

*.pdf = svn:mime-type=application/pdf;svn:needs-lock=*

*.ppt = svn:mime-type=application/vnd.ms-powerpoint;svn:needs-lock=*

*.ser = svn:mime-type=application/octet-stream;svn:needs-lock=*

*.swf = svn:mime-type=application/x-shockwave-flash;svn:needs-lock=*

*.vsd = svn:mime-type=application/x-visio;svn:needs-lock=*

*.xls = svn:mime-type=application/vnd.ms-excel;svn:needs-lock=*

*.zip = svn:mime-type=application/zip;svn:needs-lock=*

属性 官方 资料

注:本文为本站或本站会员原创优质内容,版权属于原作者及清泛网所有,
欢迎转载,转载时须注明版权并添加来源链接,谢谢合作! (编辑:admin)
分享到: