msg167337 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) * |
Date: 2012-08-03 15:40 |
My editors are configured to remove trailing spaces (this is useful for removing artifacts of indentation). The flip side of this is that my patches sometimes contain unrelated trailing spaces fixes.
Trailing spaces are not significant in any CPython source file, their presence I believe mistake. Easier once we remove all spaces and then prevent the appearance of new, than constantly face to unrelated changes. I'm not attaching a patch (it is too big, over 5 MB), anyone can create it by the following commands:
hg status -cn | tr '\n' '\0' | xargs -0 sed -i -re 's/[ \t]+$//'
It would be good if the Mercurial would had hook, which automatically remove trailing spaces or prohibit to commit patches that contain trailing spaces.
|
msg167349 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) * |
Date: 2012-08-03 19:58 |
Because CPython repository contains binary files too, they should be reverted:
hg diff | sed -nre 's/^Binary file (.*) has changed/\1/p' | tr '\n' '\0' | xargs -0 hg revert
|
msg167350 - (view) |
Author: Ned Deily (ned.deily) * |
Date: 2012-08-03 20:16 |
There already is a hook in place for the main python.org repository that checks for and rejects changesets that include files with space issues:
http://hg.python.org/hooks/file/bd04c6b37749/checkwhitespace.py
You can add it to your local repo to check patches before they are pushed.
|
msg167357 - (view) |
Author: Antoine Pitrou (pitrou) * |
Date: 2012-08-03 21:12 |
Or you can use "make patchcheck" which will (hopefully) warn you of such issues.
|
msg167421 - (view) |
Author: Chris Jerdonek (chris.jerdonek) * |
Date: 2012-08-04 17:10 |
> There already is a hook in place for the main python.org repository that checks for and rejects changesets that include files with space issues:
If there is already a hook, then why do some files have spurious white space (i.e. at the end of a line)? Is that because those issues were present prior to putting the hook in place?
|
msg167430 - (view) |
Author: Antoine Pitrou (pitrou) * |
Date: 2012-08-04 19:14 |
AFAIR the hook only applies to Python and reST files, not C files.
I think Georg wrote it, perhaps he knows the reasons.
|
msg167433 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) * |
Date: 2012-08-04 19:35 |
> There already is a hook in place for the main python.org repository that
> checks for and rejects changesets that include files with space issues:
Now I understand why there is no problem with .py files. But there are a lot of
other files (including .c and .h) with trailing whitespaces.
|
msg167434 - (view) |
Author: Georg Brandl (georg.brandl) * |
Date: 2012-08-04 19:43 |
Well, I'm -0 on extending the hook to C files.
|
msg167438 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) * |
Date: 2012-08-04 20:49 |
I found a few files where trailing spaces are significant (patches, RTF, test data). Excluding them and three generated file (Unicode data, generating scripts should be smarter), I divided the remaining into several parts:
1) the libffi library;
2) the libmpdec library;
3) other C sources;
4) the rest of the files (mainly readme-like files and build scripts).
|
msg167440 - (view) |
Author: Ned Deily (ned.deily) * |
Date: 2012-08-04 20:59 |
-1 for making wholesale whitespace changes. It potentially makes merging harder for little benefit. Imported files from other projects should definitely not be touched. IMO, the only thing potentially worth considering is extending the existing hook to C files. I'm +0 on that myself.
|
msg167444 - (view) |
Author: Stefan Krah (skrah) * |
Date: 2012-08-04 21:35 |
I'm not against whitespace cleanup every now and then, but also -0
on a hook for C files. I think that (for C) the annoyance of having
a patch rejected because of trailing whitespace outweighs the
overall benefit.
|
msg167532 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2012-08-06 02:09 |
How is it more of a nuisance for C files than for .py files?
Editor 'trim trailing' tools certainly don't care.
|
msg167535 - (view) |
Author: Chris Jerdonek (chris.jerdonek) * |
Date: 2012-08-06 03:55 |
Out of curiosity, is there a mechanism to bypass the hook on a per-file basis, if necessary? FWIW, the WebKit open source project had a similar hook (for SVN) to prevent the inclusion of tabs in source files, and a custom SVN property was used to bypass the check on a per-file basis.
|
msg167677 - (view) |
Author: Ned Deily (ned.deily) * |
Date: 2012-08-08 08:58 |
Since we've established that python files are already covered by 'make patchcheck' and the hg checkin hook and that there does not appear to be much enthusiasm for extending the hook to C files or to wholesale whitespace cleanup, the remaining issue is whether to extend 'make patchcheck' for C files. And that is the subject of open Issue8912. So I'm going to close this issue as a duplicate of that one and suggest further discussion take place there. As for a per-file bypass, I'm not aware of any nor of any need that has arisen so far for one.
|
|
Date |
User |
Action |
Args |
2022-04-11 14:57:33 | admin | set | github: 59755 |
2012-10-04 10:50:15 | jcea | set | nosy:
+ jcea
|
2012-08-08 08:58:32 | ned.deily | set | status: open -> closed superseder: `make patchcheck` should check the whitespace of .c/.h files messages:
+ msg167677
resolution: duplicate stage: resolved |
2012-08-06 03:55:26 | chris.jerdonek | set | messages:
+ msg167535 |
2012-08-06 02:09:50 | terry.reedy | set | nosy:
+ terry.reedy messages:
+ msg167532
|
2012-08-04 21:35:55 | skrah | set | nosy:
+ skrah messages:
+ msg167444
|
2012-08-04 20:59:40 | ned.deily | set | messages:
+ msg167440 |
2012-08-04 20:54:07 | serhiy.storchaka | set | files:
+ other_trailing_whitespaces.diff |
2012-08-04 20:51:52 | serhiy.storchaka | set | files:
+ c_trailing_whitespaces.diff |
2012-08-04 20:50:56 | serhiy.storchaka | set | files:
+ libmpdec_trailing_whitespaces.diff |
2012-08-04 20:49:50 | serhiy.storchaka | set | files:
+ libffi_trailing_whitespaces.diff keywords:
+ patch messages:
+ msg167438
|
2012-08-04 19:43:29 | georg.brandl | set | messages:
+ msg167434 |
2012-08-04 19:35:28 | serhiy.storchaka | set | messages:
+ msg167433 |
2012-08-04 19:14:54 | pitrou | set | nosy:
+ georg.brandl messages:
+ msg167430
|
2012-08-04 17:10:45 | chris.jerdonek | set | nosy:
+ chris.jerdonek messages:
+ msg167421
|
2012-08-03 21:12:05 | pitrou | set | nosy:
+ pitrou messages:
+ msg167357
|
2012-08-03 20:16:15 | ned.deily | set | nosy:
+ ned.deily messages:
+ msg167350
|
2012-08-03 19:58:36 | serhiy.storchaka | set | messages:
+ msg167349 |
2012-08-03 15:40:15 | serhiy.storchaka | create | |