The error message means "Your local working copy contains modified files which the update tries to delete."
If you run "hg st" on the remote server (i.e. inside of the remote repository), you should see modified files. Note that changing the permission of a file is considered a change.
So what happens is this:
- Your local Mercurial pushes the files to the remote repository
- The hook changes file in the remote repository (by modifying their permissions).
- Someone tries to delete one of those files
Mercurial always tries to prevent data loss, so the default option is "preserve local changes" (because you can always delete those files later if you want to but you might not be able to restore them).
What can you do?
Instead of "fixing" the permissions on the remote repo, refuse to accept change sets with wrong permissions. That is, instead of fixing the permissions, check them in a pretxnchangegroup
hook. If the permissions are wrong, abort. That way, you can't push as long as the permissions are broken. Docs.
Instead of modifying the working copy, copy the files into a new place and change the permissions there. This wastes some disk space (but not as much as you'd think if you use soft or hard links) but it separates concerns (special permissions from versioned files).
[EDIT]
New files, added locally then pushed to the remote repo, loose execute permissions.
They don't lose it, they didn't have it in the first place: Windows doesn't support this Unix feature.
Unfortunately, you can't tell Mercurial to set the bit from Windows.
To fix this properly, use this approach:
- Add and push files from Windows as before
- Create a cron job on the Unix server which checks the permissions and sends an email fi they are wrong.
- When the email comes in, connect to the Unix server and fix the permissions
- Commit and push the changes from Unix.
Mercurial will preserve the execute bit if you modify the file on Windows.
I suggest to put the last two steps into a script. I don't think you can completely automate it; the script will (often?) fail when someone pushes a change while it runs.
PS: I've filed a feature request asking for a better solution: Provide a way to modify the Unix permissions from Windows