Mercurial:忽略文件权限/模式(chmod)更改 [英] Mercurial: Ignore file permission / mode (chmod) changes

查看:268
本文介绍了Mercurial:忽略文件权限/模式(chmod)更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法忽略Mercurial存储库的文件权限/模式(chmod)更改?



我正在寻找类似于Git的设置:

p>

  core.filemode  - >假




  • 如下所述:


我可以让git diff忽略权限更改



更新:正确的答案是Ry4an与我的第二个评论一起回答他的答案。
< Mercurial只跟踪文件的执行权限,而不是以用户/组/其他方式执行,就像一个单独的位一样,所以取决于你试图压制的内容您可能需要调整运行 hg update '

$ b $的用户的 umask b

如果它是执行位,那么我认为唯一的选择是使用预提交钩子:

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

即在提交之前从所有文件中删除执行。



要仅对版本化文件执行相同操作,请使用 hg locate ,如 $ b

  hg locate --print0 | xargs -0 chmod a-x 

请注意,在某些情况下这可能会失败。例如在重命名期间( hg rename ),重命名之前和重命名之后的文件将被记录为使用 hg locate 。因此,挂钩将失败 chmod 文件的旧名称,并且提交将作为一个整体失败。这可以通过临时禁用钩子或在钩子结束时调用 / bin / true 来固定。


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.

解决方案

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.

这篇关于Mercurial:忽略文件权限/模式(chmod)更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆