<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.orcaware.com/svn/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Aaron.stover</id>
	<title>SubversionWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.orcaware.com/svn/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Aaron.stover"/>
	<link rel="alternate" type="text/html" href="https://www.orcaware.com/svn/wiki/Special:Contributions/Aaron.stover"/>
	<updated>2026-09-29T13:40:03Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.4</generator>
	<entry>
		<id>https://www.orcaware.com/svn/mediawiki/index.php?title=Automatic_lock-modify-unlock&amp;diff=1759</id>
		<title>Automatic lock-modify-unlock</title>
		<link rel="alternate" type="text/html" href="https://www.orcaware.com/svn/mediawiki/index.php?title=Automatic_lock-modify-unlock&amp;diff=1759"/>
		<updated>2009-02-20T00:01:38Z</updated>

		<summary type="html">&lt;p&gt;Aaron.stover: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Different versions of binary files cannot be merged. Therefore versioning of binary files should follow the lock-modify-unlock model[http://svnbook.red-bean.com/en/1.4/svn.basic.vsn-models.html#svn.basic.vsn-models.lock-unlock]. &lt;br /&gt;
This setup uses the following three measures&lt;br /&gt;
* forces users to use property svn:needs-lock on newly added binary files. Denies commits when the property is not available&lt;br /&gt;
* sets the svn:needs-lock property on all already existing binary files in repositories&lt;br /&gt;
* configures users to automatically set property svn:needs-lock on newly added binary files&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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):&lt;br /&gt;
&amp;lt;pre&amp;gt;@echo off&lt;br /&gt;
set REPOS=%1&lt;br /&gt;
set TRANSACTION=%2&lt;br /&gt;
set SVNLOOK=&amp;quot;c:\Program Files\Subversion\apache2.2\bin\svnlook.exe&amp;quot;&lt;br /&gt;
set TEMP=c:\temp&lt;br /&gt;
&lt;br /&gt;
if exist %TEMP%\tempfile%2 del %TEMP%\tempfile%2&lt;br /&gt;
for /f &amp;quot;tokens=1,2 usebackq&amp;quot; %%i in (`%SVNLOOK% changed -t %2 %1`) do @if %%i==A @echo %%j &amp;gt;&amp;gt; %TEMP%\tempfile%2&lt;br /&gt;
if not exist %TEMP%\tempfile%2 goto NOFILESADDED&lt;br /&gt;
for /f &amp;quot;usebackq&amp;quot; %%i in (`findstr /E /I /R &amp;quot;\.bmp.$ \.gif.$ \.ico.$ \.jpeg.$ \.jpg.$ \.png.$ \.tif.$ \.tiff.$ \.doc.$ \.jar.$ \.odt.$ \.pdf.$ \.ppt.$ \.swf.$ \.vsd.$ \.xls.$ \.zip.$&amp;quot; %TEMP%\tempfile%2`) do (&lt;br /&gt;
%SVNLOOK% propget -t %2 %1 svn:needs-lock %%i 1&amp;gt; nul 2&amp;gt; nul&lt;br /&gt;
if ERRORLEVEL 1 (&lt;br /&gt;
echo commit denied, binary files must have property svn:needs-lock &amp;gt;&amp;amp;2&lt;br /&gt;
type %TEMP%\tempfile%2 &amp;gt;&amp;amp;2&lt;br /&gt;
del %TEMP%\tempfile%2&lt;br /&gt;
EXIT /B 1&lt;br /&gt;
)&lt;br /&gt;
)&lt;br /&gt;
del %TEMP%\tempfile%2&lt;br /&gt;
:NOFILESADDED&lt;br /&gt;
EXIT /B 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As an alternative, this modification to the script above handles long filenames and by default is setup to work with a VisualSVN Server installation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set REPOS=%1&lt;br /&gt;
set TRANSACTION=%2&lt;br /&gt;
set SVNLOOK=c:\Progra~1\Visual~1\bin\svnlook.exe&lt;br /&gt;
set TEMP=c:\Progra~1\Visual~1&lt;br /&gt;
&lt;br /&gt;
if exist %TEMP%\tempfile%2 del %TEMP%\tempfile%2&lt;br /&gt;
&lt;br /&gt;
REM Identify all property updates and added files in current transaction and print them to tempfile&lt;br /&gt;
for /f &amp;quot;tokens=1,* usebackq&amp;quot; %%i in (`%SVNLOOK% changed -t %2 %1`) do @if %%i==A @echo %%j&amp;gt;&amp;gt; %TEMP%\tempfile%2&lt;br /&gt;
for /f &amp;quot;tokens=1,* usebackq&amp;quot; %%i in (`%SVNLOOK% changed -t %2 %1`) do @if %%i==_U @echo %%j&amp;gt;&amp;gt; %TEMP%\tempfile%2&lt;br /&gt;
&lt;br /&gt;
REM If no property updates or file additions occurred go to the end of the script&lt;br /&gt;
if not exist %TEMP%\tempfile%2 goto NOFILESADDED&lt;br /&gt;
&lt;br /&gt;
REM For each file with these extensions listed in the tempfile check that it has the needs-lock property set&lt;br /&gt;
for /f &amp;quot;tokens=* usebackq&amp;quot; %%i in (`findstr /E /I /R &amp;quot;\.bmp \.gif \.ico \.jpeg \.jpg \.png \.tif \.tiff \.doc \.jar \.odt \.pdf \.ppt \.swf \.vsd \.xls \.zip&amp;quot; %TEMP%\tempfile%2`) do (&lt;br /&gt;
REM echo &amp;quot;%SVNLOOK% propget -t %2 %1 svn:needs-lock &amp;quot;%%i&amp;quot; 1&amp;gt; nul 2&amp;gt; nul&amp;quot; 1&amp;gt;&amp;amp;2&lt;br /&gt;
%SVNLOOK% propget -t %2 %1 svn:needs-lock &amp;quot;%%i&amp;quot; 1&amp;gt;&amp;amp;2&lt;br /&gt;
&lt;br /&gt;
REM If the property wasn&#039;t set&lt;br /&gt;
if ERRORLEVEL 1 (&lt;br /&gt;
REM Display a helpful error message to the user&lt;br /&gt;
echo commit denied, binary files must have property svn:needs-lock &amp;gt;&amp;amp;2&lt;br /&gt;
type %TEMP%\tempfile%2 &amp;gt;&amp;amp;2&lt;br /&gt;
del %TEMP%\tempfile%2&lt;br /&gt;
EXIT /B 1&lt;br /&gt;
)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
del %TEMP%\tempfile%2&lt;br /&gt;
:NOFILESADDED&lt;br /&gt;
EXIT /B 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2) Recursively set svn:needs-lock property on binaries&lt;br /&gt;
&lt;br /&gt;
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):&lt;br /&gt;
- checkout a repository&lt;br /&gt;
- add to following line to a cmd script (Windows only):&lt;br /&gt;
&amp;lt;pre&amp;gt;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&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
- run the script&lt;br /&gt;
&lt;br /&gt;
3) Configure users to automatically use svn:needs-lock property on new binary files&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
- under windows the SVN config file is &amp;quot;C:\Documents and Settings\[USER_NAME]\Application Data\Subversion\config&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Replace or merge the [miscellany] and [auto-props] sections in the svn config file with the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[miscellany]&lt;br /&gt;
enable-auto-props = yes&lt;br /&gt;
&lt;br /&gt;
[auto-props]&lt;br /&gt;
### The format of the entries is:&lt;br /&gt;
###   file-name-pattern = propname[=value][;propname[=value]...]&lt;br /&gt;
### The file-name-pattern can contain wildcards (such as &#039;*&#039; and&lt;br /&gt;
### &#039;?&#039;).  All entries which match will be applied to the file.&lt;br /&gt;
### Note that auto-props functionality must be enabled, which&lt;br /&gt;
### is typically done by setting the &#039;enable-auto-props&#039; option.&lt;br /&gt;
*.bmp = svn:mime-type=image/bmp;svn:needs-lock=*&lt;br /&gt;
*.gif = svn:mime-type=image/gif;svn:needs-lock=*&lt;br /&gt;
*.ico = svn:mime-type=image/x-icon;svn:needs-lock=*&lt;br /&gt;
*.jpeg = svn:mime-type=image/jpeg;svn:needs-lock=*&lt;br /&gt;
*.jpg = svn:mime-type=image/jpeg;svn:needs-lock=*&lt;br /&gt;
*.png = svn:mime-type=image/png;svn:needs-lock=*&lt;br /&gt;
*.tif = svn:mime-type=image/tiff;svn:needs-lock=*&lt;br /&gt;
*.tiff = svn:mime-type=image/tiff;svn:needs-lock=*&lt;br /&gt;
&lt;br /&gt;
*.doc = svn:mime-type=application/msword;svn:needs-lock=*&lt;br /&gt;
*.jar = svn:mime-type=application/octet-stream;svn:needs-lock=*&lt;br /&gt;
*.odc = svn:mime-type=application/vnd.oasis.opendocument.chart;svn:needs-lock=*&lt;br /&gt;
*.odf = svn:mime-type=application/vnd.oasis.opendocument.formula;svn:needs-lock=*&lt;br /&gt;
*.odg = svn:mime-type=application/vnd.oasis.opendocument.graphics;svn:needs-lock=*&lt;br /&gt;
*.odi = svn:mime-type=application/vnd.oasis.opendocument.image;svn:needs-lock=*&lt;br /&gt;
*.odp = svn:mime-type=application/vnd.oasis.opendocument.presentation;svn:needs-lock=*&lt;br /&gt;
*.ods = svn:mime-type=application/vnd.oasis.opendocument.spreadsheet;svn:needs-lock=*&lt;br /&gt;
*.odt = svn:mime-type=application/vnd.oasis.opendocument.text;svn:needs-lock=*&lt;br /&gt;
*.pdf = svn:mime-type=application/pdf;svn:needs-lock=*&lt;br /&gt;
*.ppt = svn:mime-type=application/vnd.ms-powerpoint;svn:needs-lock=*&lt;br /&gt;
*.ser = svn:mime-type=application/octet-stream;svn:needs-lock=*&lt;br /&gt;
*.swf = svn:mime-type=application/x-shockwave-flash;svn:needs-lock=*&lt;br /&gt;
*.vsd = svn:mime-type=application/x-visio;svn:needs-lock=*&lt;br /&gt;
*.xls = svn:mime-type=application/vnd.ms-excel;svn:needs-lock=*&lt;br /&gt;
*.zip = svn:mime-type=application/zip;svn:needs-lock=*&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aaron.stover</name></author>
	</entry>
</feed>