Hooks

Marcin Kasperski Marcin.Kasperski at mekk.waw.pl
Mon Mar 15 11:31:03 UTC 2021


> -   precommit - still does not catch issues until the very end. Does not run spa
> ces when doing a rebase or evolve. 
> -   pre-commit - this catches it at the very beginning and also does not run spa
> ces when doing a rebase or evolve. 

What about binding this verification to push instead of commit? Verify
things when they are to be pushed instead of checking them on every
commit.

I am doing some similar checks even further – on the server, incoming
changesets are verified and files on tip of every new head must satisfy
some criteria (pretxnchangegroup or pretxncommit, don't remember which
things where just now). This way whoever fromever pushes, dirty commits
are rejected, user in charge must amend the change (or simply make new
commit fixing the issue).

> Ideally, it would be nice to be able to create a hook with a set of parameters s
> uch as the command that are are tracked.

It's rather easy to convert hook into extension. There you can do
whatever you need rather easily. My example of hook repacked into
extension when it started to be big:

https://foss.heptapod.net/mercurial/mercurial-update_version/-/blob/branch/default/mercurial_update_version.py#L1160

Here my case is simple but it's easy to write similar function so it
selects hooks according to some config. 

Packaging as extension has usually additional benefit of easier
installation.



More information about the Mercurial mailing list