简体   繁体   English

后克隆钩子 in.hgrc 并不总是执行?

[英]Post-clone hook in .hgrc is not always executed?

I have created a post-clone hook in.hg/hgrc.我在.hg/hgrc 中创建了一个克隆后挂钩。 This hook sometimes executed, and sometimes not, depending on which directory hg is called from.这个钩子有时会被执行,有时不会,这取决于 hg 是从哪个目录调用的。

Let the repository be in /path/to/repos/.让存储库位于 /path/to/repos/ 中。 The post-clone hook is in /path/to/repos/.hg/hgrc.克隆后挂钩位于 /path/to/repos/.hg/hgrc 中。

Cloning from /path/to/repos/, the post-clone hook is executed:从 /path/to/repos/ 克隆,执行克隆后挂钩:

$ pwd
/path/to/repos/
$ hg clone ./ /path/to/myclone/

Cloning from /path/to, the post-clone hook is not executed:从 /path/to 克隆,执行克隆后挂钩:

$ pwd
/path/to/
$ hg clone repos myclone

Why is the hgrc in my repository not read/post-clone hook not executed in the latter case?为什么我的存储库中的 hgrc 在后一种情况下未读取/未执行克隆后挂钩?

Regards, Freddy问候,弗雷迪

I suspect you need to put the hook in your ~/hgrc file, rather than your repo's hgrc.我怀疑你需要把钩子放在你的 ~/hgrc 文件中,而不是你的 repo 的 hgrc 中。

Hooks do not propagate钩子不会传播

ie. IE。 if you add hook to a repo, then clone the repo, don't expect the hook to be in the new clone.如果您将钩子添加到回购中,然后克隆回购,不要指望钩子在新的克隆中。

Here's the main text linked-to from Tom's answer , in case that page eventually changes or goes away:这是Tom's answer链接到的主要文本,以防该页面最终更改或消失:

Hooks do not propagate钩子不会传播


In Mercurial, hooks are not revision controlled, and do not propagate when you clone, or pull from, a repository.在 Mercurial 中,挂钩不受修订控制,并且在您克隆或从存储库中提取时不会传播。 The reason for this is simple: a hook is a completely arbitrary piece of executable code.原因很简单:钩子是一段完全任意的可执行代码。 It runs under your user identity, with your privilege level, on your machine.它以您的用户身份在您的机器上以您的权限级别运行。

It would be extremely reckless for any distributed revision control system to implement revision-controlled hooks, as this would offer an easily exploitable way to subvert the accounts of users of the revision control system.任何分布式修订控制系统实施修订控制钩子都是非常鲁莽的,因为这将提供一种易于利用的方式来破坏修订控制系统用户的帐户。

Since Mercurial does not propagate hooks, if you are collaborating with other people on a common project, you should not assume that they are using the same Mercurial hooks as you are, or that theirs are correctly configured.由于 Mercurial 不传播钩子,如果您与其他人在一个共同的项目上合作,您不应假设他们使用与您相同的 Mercurial 钩子,或者他们的钩子配置正确。 You should document the hooks you expect people to use.您应该记录您希望人们使用的钩子。

In a corporate intranet, this is somewhat easier to control, as you can for example provide a “standard” installation of Mercurial on an NFS filesystem, and use a site-wide ~/.hgrc file to define hooks that all users will see.在公司内部网中,这更容易控制,例如,您可以在 NFS 文件系统上提供 Mercurial 的“标准”安装,并使用站点范围的 ~/.hgrc 文件来定义所有用户都会看到的挂钩。 However, this too has its limits...然而,这也有其局限性……

That last warning may have been referring to the very next section which adds:最后一个警告可能是指下一节,它添加了:

If you deploy a system- or site-wide ~/.hgrc file that defines some hooks, you should thus understand that your users can disable or override those hooks.如果您部署定义了一些挂钩的系统或站点范围的 ~/.hgrc 文件,那么您应该了解您的用户可以禁用或覆盖这些挂钩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM