Occasionally I commit some code to the repository, add a comment/summary, then read the summary back and realise I\'ve made a mistake or should have included a bit more info
If that is the last commit, you can press "Undo" button in the commit dialog (it is an interface to hg rollback
) and then commit the same files again with a new message. If this is a commit in a middle of the tree, you need to use mq
extension to delete all later commits and reapply them. And if the commit with an incorrect summary is pushed to a public repo, you should accept and live with that, because you should not change published commits.
Phil - I'll post the same answer I just posted on this question (asked after yours):
One appropriate way to do this is to use histedit. Histedit allows you to remove, modify, combine or otherwise edit your previous commits.
Histedit does not ship with Mercurial and it cannot be used with TortoiseHg, but the command line usage is very simple:
> 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 and then issue this command:
> 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. This is a pretty trivial use of histedit, more complicated uses involved combining commits or removing a portion of some commit.
hg 2.2 just added the git
-like --amend
option. (See the hg 2.2 release notes.)
So you can do this on the command line:
hg commit --amend
See also Mercurial: how to amend the last commit?
I have not figured out how to do this in TortoiseHg.
Use mercurial queues to convert the change-sets to patches, then strip those change-sets and re-apply the patches back to your repository.
When the patches are created, they are stored in the .hg/patches folder in your repository and you can edit these (including the commit message) before you re-apply them.
TortoiseHG as long as you had not pushed:
Mark latest revision (which is to be ammended),
click the green tick on top as if you would like to commit.
Open the menu triangle right from the "commit" button on the right hand side and choose "ammend current version" instead of "commit changes".
Here you are.
Judging by the answers .. so the sum-up answer is,
Yes, it is possible if the last action was the commit of the changeset in question (in which case, execute the rollback command), and
No, it is not possible, not out of the box (without the mq extension and a lot of gruntwork), if the changeset in question has already been pushed or subsequent check-ins have been made.
I'm posting this answer because the other answers did not admit the 'no', only the 'if'. :) Feel free to vote down, I just wanted to spell out the inferences here.