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.

Local History

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

Compare with Local History

Compare with Local History

This opens the History View which offers compare and merge (see Compare and Merge in Eclipse):

History View

History View

The number of entries (and size) of the local history is configured in the following workspace setting (menu Window > Preferences > General > Workspace > Local History):

Local History Preferences

Local History Preferences

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.

Quick Diff

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):

Quick Diff Preferences

Quick Diff Preferences

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):

Quick Diff Color Marker

Quick Diff Color Marker

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:

Quick Diff Mouse Over

Quick Diff Mouse Over

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 :-)

About these ads

5 thoughts on “Eclipse Local History & Quick Diff

  1. Pingback: Eclipse Local History & Quick Diff | MCU on Eclipse | Laughing

  2. To restore earlier version of code you could simply use context menu (click on “the left editor area” with the line numbers). There are different options: “Revert line\block”, “Restore deleted lines” etc.

    Like

  3. Pingback: Eclipse Workspace Tips | MCU on Eclipse

  4. Pingback: Restore Deleted Files in Eclipse with Local History | MCU on Eclipse

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s