How can I share a commit-hook in mercurial with all fellow developers?
Asked Answered
E

3

9

we are working with mercurial and now we would like to introduce precommit hooks to keep the code clean. We would like everyone to somehow get the hooks, but we would also like to be able to update this in some centralized way. Mercurial does not version control hooks, so what would be our alternative option? Do any of you have found a solution for this? Thanks in advance!

Nemmi

Extragalactic answered 8/2, 2011 at 13:9 Comment(1)
Duplicate of #7462654.Cadi
M
10

Hooks are not cloned (as detailed in "Version-controlled extension configuration in Mercurial"), but you can have a common hgrc file (see hgrc Syntax):

A line of the form %include file will include file into the current configuration file

In that central configuration file, you can then modify the [hooks] section.

Meingolda answered 8/2, 2011 at 13:23 Comment(2)
Uhm but how is the %include file statement shared? How would having the settings in a separate file be different than copy/pasting it's contents into the hgrc?Leifeste
@Leifeste 6 years later, I am a bit fuzzy on the details, but the clear advantage of having an included file as opposed to a copied content is that is the included file (pointing to a shared common file) changes, you immediately benefit from said changes.Meingolda
F
2

If you have control over their desktops (it's a standard corporate install) you can put the hook in the system-wide entries /etc/mercurial/hgrc or /etc/mercurial/hgrc.d/ourcommithook

If you're remotely administering the machines you could automate this using something like the very excellent puppet or by building your own .rpm, .deb, or .msi installer which both installed Mercurial and places the everyone hooks in the machine-global config.

Frederique answered 8/2, 2011 at 15:34 Comment(0)
K
0

Have a look at the projrc extension. You then simply need to have designers put a small number of common lines in their ~/.hgrc files and they will automatically get pushed whatever you put in your centralized repo's repo/.hg/projrc file.

You will still need a common place to put these hooks but you probably already have some sort of shared mounted drive that users all mount, right? Or you could have a "tools" repository that everybody has to have checked out in a standard location.

Steve

Kinsfolk answered 15/2, 2012 at 16:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.