understanding strip

Evan Powers evan.powers+hg at gmail.com
Mon Jun 30 09:45:19 CDT 2008


On Fri, 2008-06-27 at 23:01 -0400, Michael P. Soulier wrote:
> Personally, I'm only interested in erasing branches, but not the merge. Is
> this possible?

Sounds like you want to convert a merge into a normal changeset having
the same content but only one parent. I don't think anybody has
written a tool to automate that, probably because most of the time
it's a spectacularly bad idea--so be sure you've thought it through.
But, doing it manually is relatively straightforward, if involved and
error-prone:

1) record the original date, user, and commit comment of the merge
(read it from the first few lines of hg export)
2) hg archive the merge revision as a tree of files
3) hg update -C to the merge revision parent you want to keep
4) blow away your working copy files, *except for .hg/*, and copy the
archive files in their place
5) delete .hg_archival.txt
6) hg addremove (possibly with "-s")
7) hg commit --date ... --user ... --logfile ...
8) hg transplant non-merge changesets above the merge onto the new commit
9) strip the old merge and branch

As you can see, this sort of history surgery isn't well supported.

- Evan


More information about the Mercurial mailing list