Recovering a deleted file from CVS using Eclipse

Life never ceases to amaze me. In this case, one day I write a rant about a Pigpen Developer who is anti-YAGNI, and then later in the week this exchange takes place.

Thursday morning, a customer tells me "Al, we're not going to need the XYZ functionality after all."

"No problem", I say, "I'll delete it."

"That would be great", they say, and I go off and delete all the code related to XYZ.

Friday morning, as I'm heading out to lunch, I meet the customer in the hallway and they say "Al, I made a mistake, we are going to need that XYZ functionality after all. Can you un-delete whatever you deleted?"

"No problem", I say, "I'll just recover it from our CVS repository when I get back from lunch."

"Thanks, Al. That would be great."

So, now that I've made my Pigpen rant, karma comes knocking to see if I have any idea what I'm talking about. Let's see ...

Recovering files from CVS using Eclipse

Recovering (un-deleting, if you prefer) files you've deleted from a CVS repository using Eclipse is a breeze, at least after you've done it once. Assuming that your project is in a CVS repository, here's all you have to do:

  1. Right-click the folder that previously contained the files you want to restore, and select Team, then Restore from Repository.
  2. Eclipse displays a list of all files that have been deleted from this directory.
  3. Select the file in the left pane that you want to restore.
  4. Then, in the right pane, select the version you want to restore.
  5. If there are multiple files you want to restore, walk through those two steps for each file. (If you've never restored a file from CVS like this before, I recommend restoring just one file to start with.)
  6. Click Finish.

That's pretty darn simple. Kudos to the Eclipse developers for making this painless.

The Eclipse recover dialog

To give you a little idea of what the Eclipse Restore from Repository dialog looks like, I've included an image here (with a few portions intentionally smudged out):

Eclipse Restore from Repository dialog (CVS)

Recovering files with other CVS tools

Of course you can do the same things with other CVS tools, including the CVS command line client, and WinCVS. If you're interested in how to work with those just drop me a line and I'll write about them.