Page MenuHomePhabricator

contrib: start building a library for simple hooks
Needs ReviewPublic

Authored by joerg.sonnenberger on Sat, Sep 7, 8:50 AM.

Details

Reviewers
None
Group Reviewers
hg-reviewers
Summary

Many workflows depend on hooks to enforce certain policies, e.g. to
prevent forced pushes. The Mercurial Guide includes some cases and
Google can help finding others, but it can save users a lot of time
if hg itself has a couple of examples for further customization.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

pulkit added a subscriber: pulkit.Sat, Sep 7, 12:20 PM

Thanks a lot for putting efforts here. I am +1 on this. I haven't looked at the code though, will try to review if no one else beats me to it.

I think we should go a step further and have some built-in hooks in Mercurial itself, like we do extensions. A good first implementation would be to define those hooks somewhere where they can be imported, add tests like they are standalone hooks. As a follow-up (read: slightly more work), we can define a new config syntax for using these hooks. e.g. builtin:reject_new_heads.

What do others think?

I like where this is going, but I wonder if these specific hooks can be written without being in-process Python hooks. Reason being that Python hooks use the unstable internals of hg and are semi-discouraged if they're avoidable.

Thoughts?

If you do stick with in-process for this, I definitely want a test included so we don't regress our own examples. ;)

I like where this is going, but I wonder if these specific hooks can be written without being in-process Python hooks. Reason being that Python hooks use the unstable internals of hg and are semi-discouraged if they're avoidable.

This is exactly why I think the Python hooks should be part of the modules shipped as part of the core distribution :)