Oded
Oded

Reputation: 795

Commiting to SVN protected repository

I used windows security to block to users the option of deleting files from the server on SVN clients. (right-click on the repository dir, and security options).

Now I want to commit a local directory back to the server, but I deleted one file from the dir. I get an error says I don't have permission to delete.

Is there any other way to bypass this?

Upvotes: 0

Views: 607

Answers (2)

Jim T
Jim T

Reputation: 12416

Deleting a file using tortoisesvn repo browser does not cause any existing files to be deleted from the windows directory containing the repository. In fact it adds 2 files - the record that the file was deleted and the comments associated with that record (ok, I simplified).

However, making any change on the repository requires the ability for the server to delete files from the windows directory containing the repository. Changes are first recorded in a new transaction file, then the repository is modified according to the transaction, then transaction file is deleted. This happens on every change, even if you're just changing a comment in a file. Preventing normal file operations in the repository's directory is going to corrupt the repository.

There is no functional difference between using tortoise svn to delete a file, and checking out a working copy, deleting the file, and committing the result. All required permissions and structural changes are identical. All the same hooks get fired in the same order and they get the same information. Both record a revision saying the file was deleted, and that revision can be reverted in both cases. You can't separate the activities. If you prevent one, you prevent the other.

Upvotes: 1

jeroenh
jeroenh

Reputation: 26772

Why are you doing this? First of all, the security rights on the repository (server-side) have actually nothing to do with the access rights of a client.

Now you should ask yourself whether you really want to trap deletes. In svn, everything is undoable at any time. When you commit a delete, svn does not physically delete anything, it just records something like 'in revision x of this repository, file y got deleted'. Subsequent checkouts/updates will obviously not check out that file anymore, but a delete can be easily undone (see svn revert).

If you're still convinced that you need to prevent users from committing deletes, you should write a pre-commit hook script, in which you can use the svnlook tool to examine the transaction being committed. Exit the hook script with a non-zero value if it contains deletes.

Upvotes: 2

Related Questions