Major whitespace clenup in CVS in HEAD

Major whitespace clenup in CVS in HEAD

by Petr Skoda -
Number of replies: 14
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
The situation with witespace in our CVS repo is not good, see the numbers - it is only our code, imported libraries are not counted. There are more than 10 000 tbas and 13 000 instances of trailing whitespace.

The plan is to fix them all in HEAD with two big commits tomorrow evening GMT.

I know that it will cause problems for people maintaining their own repos and merging from older branches, but it will help a lot when merging from 1.7 upwards.

This step was already approved by MD. If there are any major objections, please speak now.

skodak
Average of ratings: -
In reply to Petr Skoda

Re: Major whitespace clenup in CVS in HEAD

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Can we put a filter on incomving CVS commits, so that anyone trying to commit a tab or trailing whitespace gets told to try again?

It is an easy mistake to make without relaising it, and very easy to correct if it is brought to your attention.
In reply to Tim Hunt

Re: Major whitespace clenup in CVS in HEAD

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Good idea. I'll add it if someone sends me reliable code to do this!
In reply to Martin Dougiamas

Re: Major whitespace clenup in CVS in HEAD

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
To be clearer, adding the pre-commit filter to the CVS repository is not hard, but we just need a nice stable well-tested perl or sh script that can check for tabs and trailing whitepace.

This version (stolen from cvs commit messages found in the ffmpeg project) could be a starting point. Our final version has to be really well tested before it goes in obviously, because all commits would break.


#!/bin/sh

FILELIST="`echo $ | sed s/Makefile//`"

for file in $FILELIST; do
if grep -e ' ' -e ' $' $file > /dev/null; then
echo
echo "Tabs or trailing whitespace found in $file."
echo "Commit aborted, fix the issue and try again."
echo
exit 1
fi

if [ `tail -c1 $file | wc -l` = 0 ]; then
echo
echo "$file does not end in a newline."
echo "Commit aborted, fix the issue and try again."
echo
exit 1
fi
done

exit 0
In reply to Martin Dougiamas

Re: Major whitespace clenup in CVS in HEAD

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I think that if you waited until after 1.7 was released, then it would not be too big a risk if you enabled a filter like this one morning, and monitored the situation for a day to see whether it worked.

We've had to cope with worse than one day without CVS access. Just don't experiment when we are trying to get 1.7 done wink
In reply to Tim Hunt

Re: Major whitespace clenup in CVS in HEAD

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
What I was most worried about was not being able to remove the file afterwards and having to wait for sourceforge to get around to removing it. But don't worry it's not happening that soon!
In reply to Martin Dougiamas

Re: Major whitespace clenup in CVS in HEAD

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Don't tell me they make it easy to add filters, but not to remove them!
In reply to Tim Hunt

Re: Major whitespace clenup in CVS in HEAD

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Well, to change the commitinfo file in CVSROOT you need to do a commit ...
In reply to Martin Dougiamas

Re: Major whitespace clenup in CVS in HEAD

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This filter assumes everything you commit is a text file. I wonder if this is true for all of the CVS content (I just don't really know).

Saludos. Iñaki.
In reply to Petr Skoda

Re: Major whitespace clenup in CVS in HEAD

by Gustav W Delius -
Hi Petr, could you include the fixing of invalid line endings in this cleanup?
In reply to Gustav W Delius

Re: Major whitespace clenup in CVS in HEAD

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
Hi Gustav, I will try to fix the line endings too. Hmm, I knew how to locate them in windows, but will have to find a new way to do it in *nix. If you know any broken file I can start playing with, please tell me wink

thanks
In reply to Petr Skoda

Re: Major whitespace clenup in CVS in HEAD

by Martín Langhoff -
pcregrep or just plain perl are good for this. Any case of \r is bad. IIRC, Windows is \n\r and Macs are \r, where Unix is \n.

Having said that, I don't know if I like massive cleanups mixed It will complicate even merging from MOODLE_16_STABLE to HEAD. (Most cases, fixable with

cvs diff -r MOODLE_16_MERGED -r MOODLE_16_STABLE path/to/file.php | patch -p -l

But it's still a pain. OTOH, I am not opposed to a commit hook script that checks for added invalid whitespace and rejects it wink

In reply to Martín Langhoff

Re: Major whitespace clenup in CVS in HEAD

by Brian Jones -
Just a thought:

Would it not suffice to just enable the pre-commit filter and then as files are updated and committed to cvs going forward, the badness will eventually clean itself up, and us CVSers won't have to pull our hair out? We'll be getting the whitespace fix along with some other change. It should be pretty transparent that way.

brian.
In reply to Brian Jones

Re: Major whitespace clenup in CVS in HEAD

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
The current plan for tonight in HEAD is to:
  • fix all tabs
  • fix all incorrect line-endings
  • fix trailing whitespace inside files new in 1.7 (those not present in 1.6)

The imported 3rd party libraries will not be touched now.

The handling of traling whitespace will be decided later because it would break merging too much for little benefit wink