precommit mercurial hook to stop commits to the wrong branch
Faheem Mitha
faheem at faheem.info
Wed Oct 9 20:55:54 UTC 2013
Hi Mads,
Thanks for the comments.
On Wed, 9 Oct 2013, Mads Kiilerich wrote:
> 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.
I'm not sure what you have in mind when you say "implemented in python but
be launched as a separate command without using the internal API".
In any case, I'd still like to use the API, as documented for example by
http://mercurial.selenic.com/wiki/MercurialApi
I see there is also http://mercurial.selenic.com/wiki/PythonHglib
Is this perhaps what you meant? The description says
"hgapi is a pure-Python API to Mercurial, that uses the command-line
interface instead of the internal Mercurial API. The rationale for this
is twofold: the internal API is unstable, and it is GPL."
This python-hglib seems to have just arrived in Debian - it is in testing
and unstable but not in stable.
so maybe this is a best-of-both-worlds kind of thing. I guess I could try
these two alternatives (internal API and hglib).
Regards, Faheem
> 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