Created
April 15, 2010 09:41
-
-
Save michdev/366902 to your computer and use it in GitHub Desktop.
svn scripts for handling binary files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: desc: Recursively set svn:needs-lock property on binaries | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### SVN config file | |
### somewhere in "C:\Documents and Settings\[USER_NAME]\Application Data\Subversion\config" | |
[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=* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: file: pre-commit.cmd script in the repository\hooks directory | |
:: desc: 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) | |
:: source : http://www.orcaware.com/svn/wiki/Automatic_lock-modify-unlock | |
@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.$" %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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: desc: this modification to the script above handles long filenames and | |
:: by default is setup to work with a VisualSVN Server installation | |
set REPOS=%1 | |
set TRANSACTION=%2 | |
set SVNLOOK=c:\Progra~1\Visual~1\bin\svnlook.exe | |
set TEMP=c:\Progra~1\Visual~1 | |
if exist %TEMP%\tempfile%2 del %TEMP%\tempfile%2 | |
REM Identify all property updates and added files in current transaction and print them to tempfile | |
for /f "tokens=1,* usebackq" %%i in (`%SVNLOOK% changed -t %2 %1`) do @if %%i==A @echo %%j>> %TEMP%\tempfile%2 | |
for /f "tokens=1,* usebackq" %%i in (`%SVNLOOK% changed -t %2 %1`) do @if %%i==_U @echo %%j>> %TEMP%\tempfile%2 | |
REM If no property updates or file additions occurred go to the end of the script | |
if not exist %TEMP%\tempfile%2 goto NOFILESADDED | |
REM For each file with these extensions listed in the tempfile check that it has the needs-lock property set | |
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 ( | |
REM echo "%SVNLOOK% propget -t %2 %1 svn:needs-lock "%%i" 1> nul 2> nul" 1>&2 | |
%SVNLOOK% propget -t %2 %1 svn:needs-lock "%%i" 1>&2 | |
REM If the property wasn't set | |
if ERRORLEVEL 1 ( | |
REM Display a helpful error message to the user | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment