Search code examples
svnhooksvn-update

Stop svn update if file is opened


Is it possible to block an svn update of a file if the file is open, either via a wrapper or a pre-update hook?

Many colleagues in my team are running into problems with Tortoise SVN when they call SVN Update on a LaTeX file that they have open, despite trying to ensure good practice usage. When updating this way, conflicts are harder to resolve and changes are being lost.


Solution

  • Bahrep's comment about locking the file is a simple way to do it. But LaTeX files are not binary files, so it makes sense to allow Tortoise to merge changes if possible.

    TortoiseSVN can have hook scripts as part of the working copy. Special TortoiseSVN property such as svn::startupdatehook or svn::preupdatehook is then used to execute that script. Read on "client-side hook scripts" in the appropriate documentation page. Make sure to use the %REPOROOT% variable when specifying the path.

    As for the script itself this seems to be a tricky one. Maybe some tool in SysInternals toolkit can help, like Handle.exe. Maybe there is something in PowerShell that you can use.

    There is also this Stack Overflow question, with promising answers. The one with PowerShell could be even more useful than the accepted one.