The file is a python module compatible with the mercurial API that can be called via commit hooks to prevent commits with files that contain trailing whitespace.

This module was inspired by which is more fully featured.

This module has been tested with Mercurial versions: * 3.9.2


Edit your project or global hgrc and add the following lines to enable the hooks.

pretxnchangegroup.checktrailing = python:/path/to/
pretxncommit.checktrailing = python:/path/to/

pretxnchangegroup.checkdos = python:/path/to/
pretxncommit.checkdos = python:/path/to/

Sample Output


Trailing whitespace detected in changeset:24 file:src/
        3:         System.out.println("test trailing space");
        4:         System.out.println("test trailing tab");
transaction abort!
rollback completed
abort: pretxncommit.checktrailing hook failed


DOS EOL detected in changeset:25
transaction abort!
rollback completed
abort: pretxncommit.checkdos hook failed