清泛IT社区App Inventor 2 中文社区

搜索

扫码访问移动社区 移动社区,您的掌上技术专家

关注我,精彩不错过! 关注我,精彩不错过!

扫码安装最新版AI伴侣 最新版AI伴侣v2.72

Aia Store .aia 源码一站式解决方案 发布日志AI2连接测试ai2Starter模拟器

开通会员送SVIPApp Inventor 2 拓展有奖征文 VIP会员享专有教程,免费赠送基础版*技术支持服务! AI2入门必读中文文档中文教程IoT专题

查看: 800|回复: 0
打印 上一主题 下一主题

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

  • TA的每日心情
    开心
    2024-02-17 18:16
  • 签到天数: 14 天

    [LV.3]偶尔看看II

    546

    主题

    715

    帖子

    1万

    积分

    管理员

    这里没有广告...

    Rank: 9Rank: 9Rank: 9

    积分
    10709
    QQ
    跳转到指定楼层
    楼主
    发表于 2016-02-24 14:27:34 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

    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):

    1. @echo off

    2. set REPOS=%1

    3. set TRANSACTION=%2

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

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

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

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

    9. 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 (

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

    11. if ERRORLEVEL 1 (

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

    13. type %TEMP%\tempfile%2 >&2

    14. del %TEMP%\tempfile%2

    15. EXIT /B 1

    16. )

    17. )

    18. del %TEMP%\tempfile%2

    19. :NOFILESADDED

    20. EXIT /B 0
    复制代码

    As an alternative, this modification to the script above handles long filenames and by default is setup to work with a VisualSVN Server installation.

    1. set REPOS=%1

    2. set TRANSACTION=%2

    3. set SVNLOOK=c:\Progra~1\Visual~1\bin\svnlook.exe

    4. set TEMP=c:\Progra~1\Visual~1
    5. if exist %TEMP%\tempfile%2 del %TEMP%\tempfile%2
    6. REM Identify all property updates and added files in current transaction and print them to tempfile

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

    8. for /f "tokens=1,* usebackq" %%i in (`%SVNLOOK% changed -t %2 %1`) do @if %%i==_U @echo %%j>> %TEMP%\tempfile%2
    9. REM If no property updates or file additions occurred go to the end of the script

    10. if not exist %TEMP%\tempfile%2 goto NOFILESADDED
    11. REM For each file with these extensions listed in the tempfile check that it has the needs-lock property set

    12. for /f "tokens=* usebackq" %%i in (`findstr /E /I /R "\.bmp \.gif \.ico \.jpeg \.jpg \.png \.tif \.tiff \.doc \.jar \.odt \.pdf \.ppt \.swf \.vsd \.xls \.zip" %TEMP%\tempfile%2`) do (

    13. REM echo "%SVNLOOK% propget -t %2 %1 svn:needs-lock "%%i" 1> nul 2> nul" 1>&2

    14. %SVNLOOK% propget -t %2 %1 svn:needs-lock "%%i" 1>&2
    15. REM If the property wasn't set

    16. if ERRORLEVEL 1 (

    17. REM Display a helpful error message to the user

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

    19. type %TEMP%\tempfile%2 >&2

    20. del %TEMP%\tempfile%2

    21. EXIT /B 1

    22. )

    23. )
    24. del %TEMP%\tempfile%2

    25. :NOFILESADDED

    26. 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):

    1. 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:

    1. [miscellany]

    2. enable-auto-props = yes
    3. [auto-props]

    4. ### The format of the entries is:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    33. *.zip = svn:mime-type=application/zip;svn:needs-lock=*
    复制代码

    清泛网 - 专注IT技能提升
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    © 2024 tsingfun.com, Inc.  沪ICP备2020034476号-1  沪公网安备31011702000040号

    GMT+8, 2024-09-20 19:43 , Processed in 0.020664 second(s), 33 queries .