I'm attempting to disallow pushes to a Mercurial repository if a certain condition holds true. However, it is essential that if the user uses push --force
, the push goes through regardless.
I know that it's easy enough to do this on the machine that's doing the push by using the pre-push
hook, which passes in the command line arguments to the hook. However, since hooks aren't propagated, I'd have to somehow distribute the hook to every single user of the repository and rely on them not messing with it.
Therefore, I thought the way to go would be to have a prechangegroup
hook on the repository server which checked the condition and aborted the push if necessary, but I can't figure out a way to obtain the command line arguments the user used while pushing from this hook. Is there a way to accomplish this just by using a hook on the repository server?
I know that a possible workaround would be using the pretxnchangegroup
hook instead and allowing the push if the commit message of the latest changeset follows a certain pattern. However, the --force
option seems much easier from a repository user's perspective, since it wouldn't force them to potentially do a dummy commit to get the message right.