2

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.

Richard
  • 23
  • 5
  • 1
    Use [lock-modify-unlock model](https://svnbook.red-bean.com/nightly/en/svn.basic.version-control-basics.html#svn.basic.vsn-models.lock-unlock) and add the `svn:needs-lock` property. See https://svnbook.red-bean.com/en/1.8/svn.advanced.locking.html Not exactly what you are asking for, but will prevent unwanted conflicts in your files. – bahrep Feb 11 '22 at 16:38

1 Answers1

2

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.

Dialecticus
  • 16,400
  • 7
  • 43
  • 103
  • Many thanks for the svn::preupdatehook idea. I was able to link a python script to this to warn the user to close .tex files identified via the `svn status --show-updates` ouput – Richard Feb 22 '22 at 09:51