Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
857 views
in Technique[技术] by (71.8m points)

git - Mercurial: Ignore file permission / mode (chmod) changes

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...