Question

I use Eclipse for development. Without thinking, I have formatted all project. Now I click commit in svn and see that I changed every file. It is very annoying.

Is there way to return code as before formatting?

I could be make revert from svn But at this case I loose change - I will not want make it.

Was it helpful?

Solution

As a general rule, you should use a consistent coding style in one project.

If your project previously had a consistent style (that was not yours) and you accidentally formatted it with your coding style, then you can:

  1. create a project-specific formatter that is consistent with the previous coding style
  2. apply this formatting to the whole project
  3. commit again

If your project didn't have such consistency, then it's time to choose one style and apply it. However, such a commit should be separated from a commit containing actual changes in the code. Therefore you can:

  1. Use Eclipse's local history to revert the formatting (as @Seelenvirtuose suggested)
  2. Commit your actual code changes
  3. Choose one coding style for the project
  4. Create a project-specific formatter for the chosen style
  5. Reformat the project with this new formatter
  6. Do another commit with only style changes this time

OTHER TIPS

Next time, try "Undo". That works more often than you'd think.

If Undo doesn't work (anymore), then you can use the "Local History" to revert to a previous state of the file.

I suggest to first revert all the files which you didn't change.

Alternatively, you can configure the formatter to produce code which looks like what you currently have in Subversion. That way, you can format the code safely. Or at least reduce the number of differences that you currently see. That will help to clean up the mess.

Lastly, you should consider moving the a modern DVCS.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top