Mercurial:忽略文件权限/模式 (chmod) 更改

发布于 2024-10-18 09:29:54 字数 327 浏览 2 评论 0原文

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

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

core.filemode -> false
  • 如下所述:

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

更新:正确的答案是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝海似她心 2024-10-25 09:29:54

Mercurial 只跟踪文件的执行权限,而不是以用户/组/其他方式,只是作为一个位,所以根据您想要压制的内容,您可能确实需要调整 umask 运行 hg update 的用户'

如果是执行位让您困惑,那么我认为唯一的选择是使用预提交挂钩,例如:

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

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

要仅对版本化文件执行相同操作,请使用 Ish 评论中指出的 hglocate

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

但请注意,在某些情况下这可能会失败。例如,在重命名 (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 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文