5

Is it possible to temporarily disable a hook when running a mercurial command? e.g., something like:

hg push --no-hook
StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
keflavich
  • 18,278
  • 20
  • 86
  • 118

3 Answers3

7

According to this bugfeature, the following skips local hooks:

hg --config alias._pull=pull _pull

Obviously this is a hack, but it has worked since 2011, and is the only way to skip local hooks given the lack of a '--no-hooks' option.

Chris Dunder
  • 199
  • 2
  • 6
  • In case this wasn't obvious, replace all instances of `pull` with other commands (e.g. `commit`) to run those without their local hooks. – congusbongus Jan 27 '16 at 01:51
  • 1
    `hg --config alias.fpush=push fpush` doesn't appear to work. It's still running my `preoutgoing` hook. – mpen Sep 07 '17 at 18:11
4

You can't disable a remote repository's hook. But you could enable or disable a local hook via --config option:

$ hg commit -m test --config 'hooks.commit.info=set | grep "^HG_"'
andref
  • 750
  • 5
  • 20
0

If this is an outgoing or preoutgoing hook that is locally configured, you can disable it by commenting out its entry under [hooks] in .hg/hgrc. If this is a hook configured on the repository that you are pushing to (changegroup, incoming, prechangegroup, pretxnchangegroup), you will have to comment out its entry under [hooks] in the target repository's .hg/hgrc (if you have access to it).

smooth reggae
  • 2,189
  • 13
  • 14