before commit hook; list files to be committed respecting cmd arguments?

Ethan Furman ethan at stoneleaf.us
Mon Jul 11 20:26:06 UTC 2016


On 07/11/2016 10:24 AM, Ulrich Thomas Gabor via Mercurial wrote:

> I'd like to write an in-process Python hook that runs a check on the files that will be committed and based on that information has the possibility to abort the commit process.
>
> My first attempt was to use a precommit hook, which can abort a commit, but I did not find a possibility to get a list of all the files, which will be committed. There is repo[None].files(), which lists all the files that have changed, but it does not respect command line arguments. When someone appends file arguments to the hg call (e.g. hg commit -m "lorem" only_this_file.txt) I found no possibility to respect this "filter". The files method always returns all files.

I use:

[hooks]
pretxncommit.blacklist = /usr/local/bin/hgblacklist
pretxncommit.sanity = /usr/local/bin/hgsanity

to do various checks.  If the hook raises any kind of error the commit 
is rolled back.

--
~Ethan~





More information about the Mercurial mailing list