Why is preoutgoing hook executed on Strip in Mercurial?

Viewed 39

Could someone please explain why my preoutgoing hook gets executed on doing hg strip (Mercurial Strip)? Is there any chance to disable that behavior?

I'd expected the hook to run when doing hg push.

1 Answers

To avoid the execution of my hook code, I've added the following lines of code to the very beginning of my hook:

if "%HG_SOURCE%" == "strip" (
    exit /b 0
)

Both outgoing and preoutgoing will be provided with a parameter indicating the source action. In Python, this parameter is called source, otherwise you can access the environment variable HG_SOURCE:

  • hg pushHG_SOURCE is push
  • hg stripHG_SOURCE is strip

Based on that observation, you can simply evaluate the initial command.

Sources:

Related