Reverting Changesets With File Moves/Renames

Normally backing out a changeset in Mercurial is as simple as:

$ hg backout revision
$ hg merge
$ hg commit

Mercurial has a bug, however, when the revision being backed out contains file renames (moves). The backout will record the change as an add/remove, instead of a rename to the old location. Instead of using hg backout for these changes, use the following procedure instead.

Note: Benjamin Smedberg is more than happy to perform complex backouts, if these instructions are confusing or terrifying.

These instructions assume you're trying to back out revision X, and that the parent of X is XPARENT: