Monday, February 8, 2010

Multiple undo keystrokes and bam all your day's coding is gone!!!

Working on a fresh project all day that hasn't been setup in a Subversion repository and while testing out stuff in Flex Builder (which is essentially Eclipse under the hood) I made some Ctrl+Z key strokes to undo some commented lines and I noticed the build started to fail whenever I saved the reverted changes. (Flex Builder 3 is set to build on each save by default).

I ignored the initial build errors thinking heck, Eclipse had gone gaga from prolonged use and it started to freeze after brief shots of inactivity so the error would definitely go away once I perform a Clean then a Build. How wrong I was indeed.

By the time, I got over my drunkenness three source files in newly created sub-folders had vanished from my file system. My God. No. This can't be happening to me... all of todays's work gone foreever????

I figured OK maybe Eclipse was playing pranks by somehow hiding the files so I hit Terminal to do an:
ls -lpA
to view all the hidden files in the parent directory containing the missing files/sub-folders. No dice.

Next thing I'm doing
apropos undelete
and surprisingly enough I get an entry for the undelete C library function on BSD systems. How convenient. I have to dust off my C skills to write an undelete utility to avoid loosing my mind from lost work? No way.

Enter: Google
I fire up my EVDO connection and hit the search box "eclipse deletes source files" trying to point fingers squarely at Eclipse for my misery. The first result, a mailing list post from way back, precisely in 2001, where the author wrote that it was dirt easy to lose changes while working in Eclipse with someone chiming in that it is a known issue that is planned to be addressed in version 2.0.

How refreshing. This post is from 2001?? and this is like 2010 and Google somehow thinks this will solve my issue? Rather than jump off to the next result or crafting another search query, I decided to continue reading the thread a bit more as to why this ancient post should be ranked higher than the rest, I might actually learn something. Interestingly, I hit this little nugget of information regarding Eclipse:

A couple of workarounds until the issues are resolved...

As a side note, the same thing happened to me today. I was working on a
class and deleted it by mistake. What I did was load an old version from the
repository and then choose the class in the Navigator and selected "Replace
with edition from Local History". That seemed to work fine.


Then I quickly recollected how I used to ignore that menu item "Restore From Local History..." when you right-click items in the project navigator.

I highlight the parent folder, right-click to 'Restore From Local History...' and bam my files re-appear. They all contained all my most recent edit. Hurray!!!

Google's search technology is still unarguably their most valuable piece of IP on top of which everything else powered by Google resonates which is why they won't risk it being stolen if their continued stay in China still poses such risks.

I can't say for sure if I accidentally hit some keystrokes other than Ctrl+Z while working on this project causing Eclipse to think I wanted those newly created source files deleted or that multiple undo key strokes in quick succession can cause source files that were creating within a coding session (i.e. Eclipse hasn't been restarted) to vanish. Either way, I'm too scared to try to find out until I've backed up all my changes safely.

Enough pontificating, it's time to get back to work.

No comments:

Post a Comment