TortoiseHG – How to rename a changeset

One important note regardless of which method is chosen:
DO NOT MODIFY HISTORY IF SOMEONE ELSE ALREADY HAS YOUR CHANGES! The comment is part of the hash for the changeset, so if you push, a new head will be created on the current branch

To modify the comment on a Changeset using MQ

I would suggest using MQ rather than an additional extension. Also, Tortoise is MQ aware, so doesn’t require any command line work.

  • import from tip to the changeset you want to modify
  • pop all changesets after the one you want to modify
  • using Tortoise’s commit tool (note the commit button is now labeled qrefresh), modify your comment to be what you wanted it to be.
  • qrefresh
  • push all the changesets you popped above
  • finalize the patches

MQ allows for much more manipulation than this (e.g. folding), but this is a simple example.

To rename a Changeset you can use HistEdit Mercurial Extension

Histedit does not ship with Mercurial and it cannot be used with TortoiseHg, but the command line usage is very simple:

Install the extension as per the site Histedit.

  • Goto the local repo and issue the following command:
    hg histedit <rev>
    • where is the revision you want to change the comment on.
    • Histedit will generate a list of changesets and show you their SHA1. Besides each changeset there is a word indicating what histedit will do with each changeset once you close the text window.
    • Next to the changeset you want to modify – replace ‘pick’ with ‘edit’. Close the text window.
    • This created a branch with your old revision.
  • Go to TortoiseHG and refresh (see the branch and note you’re now on the parent). Don’t worry about his for now.
  • For now commit your work again in TortoiseHG (full patch) with a correct comment.
  • Go back to the command line and issue the following
hg histedit --continue
    • and another text window will appear containing the log message. Change the message to whatever you want. You can do this for multiple changesets in one go, provided the files have not been shared yet.
  • Go back to TortoiseHG and refresh. Notice you’re all good.

It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply