Can I recover a rm -rf-ed Mercurial repository?

Posted by WishCow on Super User See other posts from Super User or by WishCow
Published on 2010-04-18T16:13:36Z Indexed on 2010/04/18 16:23 UTC
Read the original article Hit count: 337

Filed under:
|
|
|

I made the mistake of wiping out my entire project directory with a quick "rm -rf project".

Of course, the .hg directory went with it. I had about 15-20 changesets, that I have not pushed to anyone, and I would really really like to get those back.

The system is a Ubuntu machine, and the partiton where the delete happened is ext3, the project consist mostly of PHP files.

I know about the guideline to not write to the disk in question.

The first idea was to use the tool named scalpel, to get the PHP files back and diff them with the current version from the repo, and somehow carve the changes out. While it succeeded, it did not recover the file names (or there is a switch I'm missing), so I'm left with a few thousand sequentially named .php files, combing through them is not an option.

Can a kind soul please save me, and suggest a way to:

a) get the repo back, or

b) get the files back, with filenames

For those wondering how I did such a stupid thing:

I was working on a file in Vim which I wanted to remove from the repository:

:!hg rm %

This complained that the file is in a subrepository, so I specified the following:

:!hg rm % -R engine

which complained that file has modifications, use -f to force. And this is when somehow, I made up the following command:

:!rm -rf % -R engine

Somehow, seeing "force" makes me do a rm -rf by reflex.

© Super User or respective owner

Related posts about mercurial

Related posts about php