Sunday, 15 November 2009

What to do when your Mercurial working directory got corrupted?

While performing a hg qrefresh today, I aborted the execution of the command because I added a wrong parameter. This resulted in a rather unfortunate situation:

$ hg status
mq status file refers to unknown node 30284bbd679b
mq status file refers to unknown node 30284bbd679b
abort: unknown revision '30284bbd679b7214334ec9a5eadbcb40d399f22f'!

Nothing would help, rolling back the aborted operation was not possible. After a bit of searching, I found Dealing With Repository And Dirstate Corruption. Apparently, my working directory suffered from dirstate corruption. According to, which deals with the fact that MQ was involved as well, the fix is simple:

$ > .hg/patches/status
$ hg debugrebuildstate -r tip

This only takes a few seconds. Executing hg status after that took quite a while -- more than an hour in fact (it was the mozilla-central repo after all) -- but then my working directory state was recovered to the tip, and all operations on it could be performed again.

This does not actually change the tree, the changes applied to the code before were still present, so I didn't lose any work. Emptying .hg/patches/status also doesn't destroy your patch queue, it only makes MQ forget about which patches are currently applied.

Rebuilding the dirstate makes Mercurial forget about which files were added to the working directory though, so you have to hg add any files that you created yourself.

You are in a bit of trouble with MQ now unfortunately, because now you have changes in your working directory that are also partially covered by the patch (or patches) in your patch queue. You can't simply hg qrefresh, because MQ thinks there are no patches applied (remember, .hg/patches/status was cleaned).

Probably the easiest way forward is to save away the current state using hg diff > ../patches/backup.diff, hg revert the working directory, qpush all the patches back into the tree that were applied before the mishap, do an interdiff (Cygwin patchutils package for the Windows sufferers amongst you) between the backed-up diff and the output of hg qdiff, and then apply the output of the interdiff to the working directory.

I didn't go that route because I didn't really care about what was in my patch queue, so I just got rid of it and created a new queue.

Saturday, 31 October 2009

Cygwin and uuidgen

Note to self: uuidgen is part of Cygwin's e2fsprogs package. Oh, and, yes, packages are searchable (but the setup UI as well as their website could use an overhaul...).

Sunday, 18 January 2009

7 things…

I love internet memes as much as the next guy, so here it goes. Wladimir tagged me, hoping that I would finally start to blog. So I did.

The rules:

  1. Link to your original tagger(s) and list these rules in your post.
  2. Share seven facts about yourself in the post.
  3. Tag seven people at the end of your post by leaving their names and the links to their blogs.
  4. Let them know they’ve been tagged.

The facts:

(In no particular order.) Are those things surprising? I don't know, but how would I know what surprises you anyway.
  • I actually quite like statically type-checked languages (especially if they use type inference).
  • I love cheesy movies, but don't like cheesy music.
  • After almost two years in the Netherlands, I still can't speak a single sentence of Dutch (except if you count «Dankjewel.» — which means «Thank you.» — as a sentence). Similar problems apply to listening. Nevertheless, I try to infer the meaning of the sentence by comparing with English and German, which can sometimes lead to rather ridiculous situations. A co-worker once asked me if I wanted some “pepernoten”, which I immediately translated to “paper notes”. I figured that he probably wanted to express that it's going to be a longer discussion, and pen and paper would be useful to remember the decisions taken. So I promptly got up, walked back to my desk and fetched my notebook and a pen. Turns out, pepernoten are actually a cookie-like candy, and this co-worker was just offering me some.
  • I love DIY, but I completely suck at it. Details are withheld.
  • I hate trailing whitespace, tabs, and inconsistency in general (ok, that should come to no surprise at all I guess…).
  • To all the people out there who still don't get what XUL is about: no, I have absolutely no experience with web design!
  • I don't like Swiss mountains. Or any mountain, really. They're too steep.


(This meme was not my idea!)
  • Alex Vincent, since we all love your dancing
  • Jesse Ruderman, because of his deep thoughts about porn
  • John Resig, because the last time I met him, I didn't have enough time to talk to him
  • Johnny Stenback, because the planet needs more of him
  • Massimiliano Mirra, to get his blog out of that lethargic state
  • Sergi Mansilla, since this guy is simply interesting
  • timeless, because I want to see a “7 things” post followed by a “What could be done?” post