开发者

How to validate and enforce commit message in Mercurial?

What are all steps required to validate commit message with set of regular expressions? We want to work in semi-centralized set-up so I need a solution for the developer clone (local repository) and for our central clone (global repository). I read about Mercurial Hooks but I am a little bit lost how to开发者_开发知识库 put all things together.

For local repository I need a way to distribute validation script across my developers. I know that hooks do not propagate when cloning so I need to a way to "enable" them in each fresh clone. It would be done as a part of our PrepareEnvironement.bat script that we run anyway on each clean clone.

To be double safe I need similar validation on my global repository. It should not be possible to push into global repository commit that are not validating. I can configure it manually - it is one time job.

I am on Windows so installing anything except TortoiseHG should not be required. It was already a fight to get Mercurial deployed. Any other dependencies are not welcomed.


You can use the Spellcheck example as a starting point. In each developer's configuration, you need to use the following hooks:

pretxnchangegroup - Runs after a group of changesets has been brought into local from another repository, but before it becomes permanent.

pretxncommit - Runs after a new changeset has been created in local, but before it becomes permanent.

For the centralized repo, I think you only need the pretxnchangegroup hook unless commits can happen on the server, too. However, you will need the Histedit extension for each of the developers if the remote repo is the one rejecting one or more of the changesets being pushed. This extension allows them to "edit" already committed changesets. I would think in most cases, the local hooks will catch the issue, but like you said, "just in case."

More details about handling events with hooks can be found in the Hg Book.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜