8

Is there a way to ignore file permission / mode (chmod) changes for a Mercurial repository?

I'm looking for a setting similar to Git's:

core.filemode -> false
  • as described here:

Can I make git diff ignore permission changes

Update: the correct answer is Ry4an's together with my second comment to his answer.

Community
  • 1
  • 1

1 Answers1

6

Mercurial only tracks the execute permission on files and not in a user/group/other way, just as a single bit, so depending what you're trying to squelch it's possible you really need to just adjust the umask of the user running hg update'

If it is the execute bit that's getting you, then I think the only option is to use a pre-commit hook like:

[hooks]
pre-commit = find $(hg root) -type f -print0 | xargs -0 chmod a-x

that, removes execute from all files before committing.

To do the same only on versioned files, use hg locate as pointed out in Ish's comment:

[hooks]
pre-commit = hg locate --print0 | xargs -0 chmod a-x

Note, though, that this can fail under certain circumstances. For example during renames (hg rename) both the file before the rename and after the rename will be recorded as versioned using hg locate. Therefore the hook will fail to chmod the old name of the file and the commit will fail as a whole. This can be "fixed" by either disabling the hook temporarily or by calling /bin/true at the end of the hook.

Community
  • 1
  • 1
Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
  • I'm not sure whether that command will fix it. I don't want to change my umask (which is a secure 700 or 077 if you like), but I'm not bothered by running a chmod command before commit (even manually). The problem is however that I ran that command manually and it didn't fix a thing. `hg status` still shows modified files, `hg diff` shows no differences and `hg diff --git` will always say that the permissions were changed (to the current ones - no matter what the old ones and the new ones were) What can I do? –  Feb 22 '11 at 12:25
  • An update: your answer is basically correct; the problem is that my repoository contains tens of thousands of files each with their own specific "x" bit permissions. In my new local copy I was basically trying to do a global chmod for all files - which contradicted the specific "x" permissions for each of the files (that Mercurial had stored). I think I'll just commit the "x" bit for ALL files. This is definitely something that can't hurt the production server. –  Feb 22 '11 at 14:01
  • 1
    I had the www-data user creating files, owned by www-data so attempting to modify them through a permission error and exited early. this worked for me to target only versioned files: `pre-commit = hg locate --print0 | xargs -0 chmod a-x` – lsh Mar 11 '13 at 13:51
  • This is not working for me. How can I fix this? I am missing something? – Romisha Aggarwal Dec 04 '14 at 06:55
  • 3
    You'll need to be a lot more specific about how its' not working for you. – Ry4an Brase Dec 04 '14 at 19:07