2

I have no idea how this happened but right after re-factoring a variable name (a final static int), the file showed a much earlier version of the same file without any ability to restore back all the hours of work I put in.

This looks like a bug to me or... "undocumented feature" (i.e. unfortunate key-combination that erases hours of work, even if stored on file)?

Has anyone experienced this?

Is this a well known behavior of Eclipse?

ateiob
  • 9,016
  • 10
  • 44
  • 55
  • 1
    Sounds like a bug. What happens if you try to undo the refactoring ? For what it's worth I have never encountered anything similar. Also, do you not see a desirable version of the file in the local history of eclipse ? – Ashutosh Jindal Aug 06 '12 at 22:48
  • @AshutoshJindal When I tried to undo the refactoring, only the refactoring was undone. Hours of changes that preceded it were simply lost. Where do I find that local history of Eclipse? – ateiob Aug 07 '12 at 13:46
  • I have put the details of the local history in my answer below. – Ashutosh Jindal Aug 07 '12 at 13:57
  • I have been hitting this bug ever since I started developing on a Mac. Is there a ticket for this in eclipse? – btiernay Jan 10 '13 at 12:32

1 Answers1

8

Recovering work from Local History

Try recovering the lost work by using the 'Local History' feature of Eclipse.

Right click on a file and click on Compare With -> Local History... like so :

Local History

Once you do that, you should see a History view with timestamped entries like so :

enter image description here

Double clicking on those should allow you to go to a specific version of the File. You should be able to recover your work if you go to timestamped entry just before the apocalyptic refactoring.

For more details see this Eclipse help page.

Local History Preferences

This feature can be most useful to get back work which otherwise would be lost. In order to increase the amount of history per file (Maximum Entries per file) and the longevity of this history (Days to keep Files), try increasing the default values by going to Preferences -> Workspace -> Local History :

enter image description here

Ashutosh Jindal
  • 18,501
  • 4
  • 62
  • 91
  • This is incredible! I didn't know about this feature. I can see versions going back to 24 hours ago. Is it possible that I somehow (unknowingly, via a key combination or a bug in the refactoring) triggered a version reversal? I will never know, so I am accepting your answer now. – ateiob Aug 07 '12 at 14:08
  • 1
    @ateiob, I can't believe how many time this local history feature has been a lifesaver ! :) . I am glad it helped. As far as I know, by default there is no shortcut to do an auto-reversal to previous version. The best there is a 'Revert File' option when you right click on a file. This reverts it to the last saved version. Also, if you find this feature useful, check out the last section titled `Local History Preferences` that I just updated my answer with. – Ashutosh Jindal Aug 07 '12 at 14:19
  • I definitely find this useful. Next time something like this happens, I'll know what to do. Thanks! – ateiob Aug 07 '12 at 14:59