Let’s keep the blame history clean

I’ve started to believe that commit messages are a very important part of our code history.  I think that they should provide a clear description of what the change does, what’s the corresponding bug number, who reviewed and approved the patch, etc.  I think you should even include a lengthy description of why the patch does what it does, if needed, in a multiline commit message, like this.

We’ve started to use some magic tokens like CLOSED TREE and DONTBUILD which are not really part of the changeset you’re pushing, but instruct our automated tools to modify their behavior.  This is fine because it let’s us do things that we can’t do otherwise, but it messes the blame history up when somebody is looking at your changeset years from now.  I’ve started to use a solution which I think is elegant and cheap: using empty commit messages.  In order to use these tokens, you can create an empty changeset as the topmost changeset that you’re going to push, like this:

hg qnew -m 'Try to fix things so that we can reopen our CLOSED TREE' magictoken
hg qfinish .
hg push

It’s been some time that I’m switching over to this technique, and I thought I should share it in case others are interested in using it too.

Posted in Blog Tagged with: ,