precommit mercurial hook to stop commits to the wrong branch
Mads Kiilerich
mads at kiilerich.com
Wed Oct 9 14:48:19 UTC 2013
On 10/09/2013 11:09 AM, Faheem Mitha wrote:
> Ry4an kindly replied with a bash solution. I think I would prefer a
> Python version, but that would use the Mercurial "not-an-api", as
> Ry4an put it. Does this look practical? If anyone feels like taking
> the time to sketch an approach, I'd appreciate it. Regardless, any
> comments would be appreciated, Thanks.
You mention the reasons that a small script probably is the best
solution. It could be implemented in python but be launched as a
separate command without using the internal API.
That is not perfect but that is how it is.
However, a development idea / "feature request":
Introduce a new hook type that takes a revset in the hook configuration.
Perhaps with different variants/configurations for rejecting when either
none, any or all revisions is matching. Perhaps also with a template for
which message should be shown to the user.
This would essentially be very much like something like
myhook = ! ( hg log -r "..." --template "...\n" | grep . )
but cross platform and more efficient and very easy to configure.
My gut feeling is that it would be so generic and useful that it would
have a good chance of getting accepted upstream.
/Mads
More information about the Mercurial
mailing list