2

I have created a post-clone hook in .hg/hgrc. This hook sometimes executed, and sometimes not, depending on which directory hg is called from.

Let the repository be in /path/to/repos/. The post-clone hook is in /path/to/repos/.hg/hgrc.

Cloning from /path/to/repos/, the post-clone hook is executed:

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

Cloning from /path/to, the post-clone hook is not executed:

$ 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?

Regards, Freddy

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81

2 Answers2

0

I suspect you need to put the hook in your ~/hgrc file, rather than your repo's hgrc.

Hooks do not propagate

i.e.. if you add hook to a repo, then clone the repo, don't expect the hook to be in the new clone.

Tom
  • 6,325
  • 4
  • 31
  • 55
0

Here's the main text linked-to from Tom's answer, in case that page eventually changes or goes away:

Hooks do not propagate


In Mercurial, hooks are not revision controlled, and do not propagate when you clone, or pull from, a repository. 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. 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. 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.

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81