3
votes

My company's svn repo has a lot of MS Word docs in it. We've implemented a policy that all .doc files must have the svn:needs-lock property set to prevent parallel access on files that are hard to merge (we've also done this for xls, ppt, pdf etc.).

We've implemented the policy by distributing a svn config with auto-props set appropriately for all relevant document types. We've also set up a pre-commit hook that checks that all added files of these types have the needs-lock property set (i.e. if they forget/are too lazy to update their svn config file, they won't be able to add any docs to the repo).

The problem I'm having, however, is that the pre-commit hook fails when users try to import files into the repo, e.g. some users like to add files directly thru TortoiseSVN's Repo Browser, which effectively is an svn import.

Through testing on other file types, I have seen that doing an import does in fact apply the auto-props listed in my config, but they don't seem to be applied at the point that the pre-commit hook runs. When importing .doc files, the hook fails, saying that the needs-lock property is missing.

Is there really much difference between adding a single file to a working copy and committing it vs importing a file directly? Do we need to tailor our precommit hook in some way to cater for this scenario?

1
How are your users importing files? When I drag and drop a file onto TortiseSVN's repo browser, the auto props are adding the svn:needs-lock. You may need to doublecheck that the users in question are using correct svn config (maybe they missed the update to include Word?). It might also be good to double-check your pre-commit hook from a workstation where you know the svn config deliberately leaves off the autoprops.ThatBlairGuy
That's my point - I've tried it myself and I know I have the right config file. When the hook is disabled, I can import Word docs and the autoprops get applied (as you suggest). Once the hook is in place, however, it fails as the auto-props don't appear to have been set by the time the hook runs. Is there any time after the pre-commit hook that properties could be applied? I don't see how it's possible really - the changes are just about to be committed...James Tisato
What happens if you deliberately use the wrong config? Does the pre-commit hook reject it? The behavior you're seeing doesn't make sense to me either, and it's not something I can reproduce. That makes me think there's something else going on.ThatBlairGuy

1 Answers

1
votes

Solved it...my fault too.

The autoprops were defined incorrectly. I had entries such as:

*.doc = svn:needs-lock

when I should have had:

*.doc = svn:needs-lock=*

i.e. actually set a value for the needs-lock property, as you would for any other property like svn:mime-type.

The irritating issue is that the broken config works just fine for add operations. It doesn't seem to matter that the "=*" is missing from the end of the autoprops definition. The * value of the property appears to get set anyway.

When you do an import, however, Subversion isn't as nice and doesn't fix your borked autoprops setting automatically.

I accept that this was my fault, but the behaviour should be consistent across both add and import operations.