As I started with Mercurial, from the very beginning I had a feeling that one day I would make a mistake in recording the message that accompanies a commit. It seemed very likely that I would forget to make note of some important change I had made to a file. Of course, there was also the possibility of typos. This is what happened a couple of days back; I committed a revision with an incomplete and partly incorrect message. I had intended to do something, changed my mind while I was modifying the file, but wrote a message which reflected my original intentions and hit enter. What made the problem worse is that I did not realize this until I had made a couple of subsequent commits. I searched on Google to find how I could fix my mistake. I found a couple of ways, but they seemed a little confusing, especially given my lack of experience with version control systems. Here I explain the method that I felt was the easiest and most straightforward to use. This involves using the histedit extension for Mercurial. The extension can do more than just change a commit message, but I will focus only on this functionality, hoping that this will make the process clearer to follow.
- Install histedit.
If you have already installed histedit, you can skip this step.
- Download histedit.
- Open the terminal and navigate to the directory where you want to save histedit. For
example, I have saved it in ~/Dropbox/Mercurial_Extensions.
- At the terminal prompt type:
hg clone https://bitbucket.org/durin42/histeditThis will download the histedit extension in your present working directory.
- Open .hgrc file.
This file is usually located in your HOME directory. If so, navigate to your home folder by typing cd ~ at the terminal prompt and pressing enter.
- Then type open .hgrc and press enter.
[extensions] histedit = ~/Dropbox/Mercurial_add_ons/histedit/hg_histedit.pySave the file.
Note that you may have to modify ~/Dropbox/Mercurial_add_ons/
part of the path to point to the directory where you downloaded
and saved the histedit extension.
changeset: 5:48f58ff8250eAt the terminal prompt, either type:
hg histedit -r 5and press enter or, type
hg histedit 48f58ff8250eand press enter.
This will open a file with a list of changesets in a text editor. The first changeset is the one that you specified. The list will look something like the one shown in the following image.
Go here for more information on histedit.