Eclipse Local History & Quick Diff
I worked long hours on my project, and it was working well. But after a series of edits, somehow the application was not working the way it should. What did I change to break my code? Usually I smile, because I have things in a version control system. But: not this time (I should know better!). Luckily there are some ways to find out what has been changed: with the Local History and Quick Diff.
Even if not using a version control system, Eclipse has a local history built-in. To compare and diff with the history, I use the menu
This opens the History View which offers compare and merge (see Compare and Merge in Eclipse):
The number of entries (and size) of the local history is configured in the following workspace setting (menu Window > Preferences > General > Workspace > Local History):
Note: keeping a long history might slow down Eclipse, especially at workspace closure time (see CodeWarrior Tool Tip #3). So better not to keep too much of history.
The Local History is nice, but there is even a faster way: Quick Diff!
Quick Diff can be enabled (if not already done) in the workspace settings (menu Window > Preferences > General > Editors > Text Editors > Quick Diff):
In the settings I can change the colors, and as well what to use as reference ((Version on Disk, Latest CVS Version or Pristine SVN Copy).
Note: There seems to be a problem (oversight?) in Eclipse (at least 3.6) with using ‘Version on Disk’: With saving a file the Quick Diff markers are gone too . But it works as expected with the SVN settings. Another good reason to use SVN .
There is a general option to enable Quick Diff, and I have enabled as well the ‘Show differences in overview ruler’.
What it does: it shows the differences in the left editor area (where usually the line numbers are):
The colors are as configured in the Quick Diff preferences shown earlier.
If I move the mouse over the marker, a pop-up window shows up:
The first character in the pop up indicates what has changed:
- >: changed line
- +: inserted line
- -: deleted line
Note the ‘Press ‘F2′ for focus’: That way I copy and restore my earlier version. Quick is simple and fast and gives me an immediate access to the earlier version.
Happy Quick Diffing