style cleanup that doesn't trample svn blame?
Asked Answered
M

4

9

I'd like to use Eclipse's formatter to fix some poorly styled code, but there's a huge downside to killing all the metadata in the repository about who is responsible for what. Any thoughts on ways to get around this? Perhaps it is just completely impossible...

Modal answered 27/3, 2009 at 4:30 Comment(0)
E
8

You can tell blame to ignore whitespace changes:

svn blame -x -w file/path

Of course that only works if your style fix doesn't change more than whitespaces.

Euchre answered 27/3, 2009 at 7:8 Comment(3)
This looks great but it doesn't work for me. What's the magic? What client and platform are you currently using?Catacomb
Tortoise svn ignores whitespace changes per default (there is a checkbox to change this).Insessorial
If you want it to also ignore changes in newlines (CRLF vs. LF), use svn blame -x -w -x --ignore-eol-style. See svn help blame and this question.Ramage
A
1

The history is still there, you'll just have to look at a blame prior to the cleanup revision.

This is one good reason to have a style standard. Indentation changes can cause a lot of merge conflicts, etc. "Poorly styled" to one is well written to another.

Apeak answered 27/3, 2009 at 4:39 Comment(1)
sadly, there's a large base of poorly styled code to start. I guess one pain point is that eclipse annotations only show the most recent change. And people use them a fair amount.Modal
C
-1

When reformatting code, I usually only fix the indentation. There are just too many cases where the automatic formatter ruins a carefully hand-formatted section.

Chopfallen answered 27/3, 2009 at 9:38 Comment(0)
A
-1

Another solution would be to add a pre-commit hook that compare the committed file with its formatted version. If there is no difference, the commit is accepted.

Otherwise, a simple message "Code not formatted : commit rejected" would inform your developers to style their modified files prior to commit.

Combined with the Stefan's answer, you still can use blame with -w option and moreover, you do not override the developer's names.

One drawback is that you won't be able to style your whole repository is one pass. Files will be styled as they are modified. Often used files will be quickly styled whereas some might never been updated.

Amaryllidaceous answered 17/1, 2011 at 16:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.