3

I ran hg commit --amend to amend a commit, but now I want to go back to the commit before I amended it. The commit hash of the commit before the amend does not appear to show up in hg log. So how do I do this?

2 Answers 2

4

If you enable the evolve extension, changesets that did get removed with "hg commit --amend" no longer get overwritten. Instead they are hidden with obsolesence markers, but can still be viewed and restored to a normal changeset.

To view hidden changesets from the command line, just add --hidden to a normal command, e.g. "hg glog --hidden -l 10". In tortoise, the filter toolbar (^S) has an icon that displays hidden changesets.

Evolve isn't yet part of the official mercurial but is due to become so. [As you see, it is supported by tortoise already.] I have been using it for ages and it works very well. It's much easier than scrabbling around trying to find an old bundle that's been given an obscure name from a date that you can't remember any more. The full history is all there in your local repo.

Sign up to request clarification or add additional context in comments.

1 Comment

Newb question: given the node ID or changeset number for the obsolete changeset, how do I restore to that one? I.e. how do I mark it "not obsolete"?
1

commit --amend command creates a backup in the .hg/strip-backup directory.

So what you need to do now is to perform

hg unbundle .hg/strip-backup/<your-backup-name> 

Where <your-backup-name> is the name of backup is the one that was told you when you performed amend.

After you do that - the original changes are re-applied to the original root and you may strip whatever you don't need anymore.

7 Comments

How do I determine the backup name? I see it when I run the hg commit --amend command, but is there a way to find it if you don't remember the output of that command?
Well, just check what you have in that directory and try to correlate backups time and your amdend command time.
Hmm okay, that works. I do a lot of amends on a lot of bookmarks... Is there no better way?
You can inspect a backup by doing hg incoming <backup>.hg. As long as the parent of the backup still exists it will dump the entries in the backup and you can read the log entries' comments too verify it is the right one.
@MarkTolonen I think OP meant that they want to automate it as much as possible so that they didn't do it manually on a lot of backups
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.