Search code examples
version-controlmercurialdvcsreadonly

Preserving read-only flags in Mercurial (or equivalent)


We'd like to prevent changes to SQL migration scripts that are in source control and have already been applied. Is there a way to mark files (specifically, SQL migration scripts) as read-only and persist this in source control?

We could resort to pre-commit hooks in our central repository, but this would require users to perform some advanced mercurial operations to undo their local commits.

Failing that, any other suggestions? Thank you.


Solution

  • Have a look at the AclExtension. It allows you to specify access controls in a variety of ways.

    In your case, you could try making the scripts "read-only" by disallowing all changes to those files for all users (see the DONT-TOUCH-THIS.txt example).

    Note that this still requires a hook, but at least saves you the trouble of writing one yourself. You could have all developers agree to use the pretxncommit hook, which prevents a commit transaction from taking place if the ACL permissions are violated.