msg174810 - (view) |
Author: Alyssa Coghlan (ncoghlan) *  |
Date: 2012-11-04 15:04 |
Setting up the same commit checks locally that the main repo enforces for incoming patch sets can save a great deal of frustration with the server rejecting "hg push" for changes (this can be especially frustrating if you have already merged changes across branches). The committer section of the devguide [1] should explain how to: 1. Check out the hooks repo from hg.python.org 2. Configure the whitespace checking hook by adding this to hgrc for the relevant repo(s) (adjusting the path appropriately for the checked out location of the hooks repo): [hooks] commit = python:~/devel/hg_hooks/checkwhitespace.py:check_whitespace_single [1] http://docs.python.org/devguide/committing.html#committing-and-pushing-changes |
|
|
msg174812 - (view) |
Author: Ezio Melotti (ezio.melotti) *  |
Date: 2012-11-04 15:10 |
Configuring the editor to remove trailing whitespace, and using make patchcheck are other valid solutions to this problem. |
|
|
msg174814 - (view) |
Author: Alyssa Coghlan (ncoghlan) *  |
Date: 2012-11-04 15:33 |
Sure, but both of those can fail (forgetting to run make patchcheck, using a different editor from your normal one for some reason) Once the commit hook is set up properly, you get alerted to the problem as soon as you try to commit, rather than having to untangle a merge chain when you realise on pushing that you stuffed up the whitespace in the original bugfix commit. |
|
|
msg174815 - (view) |
Author: Ezio Melotti (ezio.melotti) *  |
Date: 2012-11-04 15:44 |
I'm not against your proposal. If the goal is to explain how to get rid of trailing whitespace then the other solutions should be mentioned too (I think made patchcheck already is). If the goal is to show how to set up local hooks and where to get them, then the other solutions don't belong there. |
|
|
msg175374 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2012-11-11 17:29 |
I would be helped by such an explanation in the devguide. |
|
|
msg240900 - (view) |
Author: Carol Willing (willingc) *  |
Date: 2015-04-14 15:01 |
Adds whitespace checking hook setup information to Minimal Configuration section of devguide [1]. Patch is ready for review. [1] https://docs.python.org/devguide/committing.html#minimal-configuration |
|
|
msg240964 - (view) |
Author: Ned Deily (ned.deily) *  |
Date: 2015-04-14 17:35 |
The wording of the patch looks good to me other than one issue: which hook to use. I notice Nick's suggestion is to use the hg "commit" hook. But in the comments for the checkwhitespace hook itself, "pretxncommit" is the suggested hook. The difference between them, AFAIK, is that the "commit" hook is executed after the changeset has been created and applied in the local repo, while the "pretxncommit" hook is called before the changeset is committed and can thus abort the commit. So in either case, you'll see the warning message from the hook if the changeset has extraneous white space but when using the "commit" hook the changeset will be applied anyway and, to fix it, you either have to strip it or commit a fix in an additional changeset. There may be some workflows where using "commit" is a better choice (like when using mq) but I think in general using the "pretxncommit" hook is the better choice. Opinions? https://hg.python.org/hooks/file/default/checkwhitespace.py#l10 |
|
|
msg240994 - (view) |
Author: Carol Willing (willingc) *  |
Date: 2015-04-14 19:28 |
Ned, Thanks for the review and feedback. It seems reasonable to me to mention both the "pretxncommit" hook as well as the "commit" hook as well as your brief comments on the difference between the two. I'll make that change to the patch and resubmit. |
|
|
msg241083 - (view) |
Author: Carol Willing (willingc) *  |
Date: 2015-04-15 05:47 |
Patch is ready for review. Ned's feedback on "pretxncommit" hook is added. |
|
|
msg241085 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2015-04-15 06:09 |
New changeset b494a25915a9 by Ned Deily in branch 'default': Issue #16405: Explain how to set up the whitespace commit hook locally. https://hg.python.org/devguide/rev/b494a25915a9 |
|
|
msg241086 - (view) |
Author: Ned Deily (ned.deily) *  |
Date: 2015-04-15 06:13 |
Thanks for the patch, Carol. (I made a few minor changes before committing: to the file paths and to make it clearer that one should choose one of the hooks.) |
|
|
msg241997 - (view) |
Author: Alyssa Coghlan (ncoghlan) *  |
Date: 2015-04-25 06:49 |
Oh, so *that's* why my local hook isn't aborting commits when the whitespace check fails :) |
|
|