2
votes

I accidently stripped a changeset in my mercurial repository and removed way too many changesets. I knew it would remove descendants, but for some reason I assumed it would only remove descendants on that branch or branches that started off of one it's in-branch descendants. Instead it removed ALL changesets from every branch that was committed after the stripped revision.

The mercurial documentation states the following:

strip is not a history-rewriting operation and can be used on public changesets

Since the changesets exist somewhere since it isn't a history rewriting operation, then how can I recover them?

1

1 Answers

3
votes

Mercurial backs up all backup bundles of stripped patches (ie: strip, amend, etc) within a folder called "strip-backup" within your repository. This directory is located at <repository-root>/.hg/strip-backup.

Within this folder you'll see backups of all the changes, but they'll have hashes as names in the format #hash#[-amend]-backup.hg. Sorting this in chronological order may help you locate the correct one assuming you know when you ran the bad strip operation. If you do not you should restore all bundles in reverse chronological order until the correct changesets have been restored.

The command to perform the restore operation is:

hg unbundle <path-to-bundle-file>
hg update