Mercurial:忽略文件权限/模式 (chmod) 更改
有没有办法忽略 Mercurial 存储库的文件权限/模式 (chmod) 更改?
我正在寻找类似于 Git 的设置:
core.filemode -> false
- 如下所述:
更新:正确的答案是 Ry4an 以及我对他的答案的第二条评论。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Mercurial 只跟踪文件的执行权限,而不是以用户/组/其他方式,只是作为一个位,所以根据您想要压制的内容,您可能确实需要调整
umask
运行hg update
的用户'如果是执行位让您困惑,那么我认为唯一的选择是使用预提交挂钩,例如:
在提交之前从所有文件中删除执行。
要仅对版本化文件执行相同操作,请使用 Ish 评论中指出的
hglocate
:但请注意,在某些情况下这可能会失败。例如,在重命名 (
hg rename
) 期间,重命名之前和之后的文件都将使用hglocate
记录为版本。因此,钩子将无法chmod
文件的旧名称,并且提交将整体失败。这可以通过暂时禁用挂钩或在挂钩末尾调用/bin/true
来“修复”。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 runninghg 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:
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: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 usinghg locate
. Therefore the hook will fail tochmod
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.