Can any one recommend a tool that will allow me to define a set of coding style requirements, and prevent anything that violates this style from being committed into the main HG repository.

I know that I can use hooks to prevent something getting into the repo. But I am not aware of any tools that can perform this sort of style analysis.

Things like my $newArrayRef = $result; would be allowed but $newArrayRef= $result; would not. And defining if a project uses camel case or underscores for variable names.

It would be nice if it could also check for anti-patterns in the code.


1 Answer 1


For JavaScript there is JSLint which is itself written in JavaScript. The answer to this SO answer details a couple of possibilities for perl. In either case you can wrap the call in a process that returns 0 if all the rules are met and -1 otherwise then call it in a pre-commit hook.

See the redbook entry on hooks for more information and the config section on hooks for more information. You might wish to allow local commits, (possibly with warnings), but block push & pull, (with preoutgoing &/or prechangegroup), until the issues are all resolved as this would allow the user to commit changes to the local repository, sort them out, then commit & push the final version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.