What's the best way to back out multiple changesets in mercurial?

mercurial

Solution

There is `--collapse` option for `rebase`.

Helgi's answer can be upgraded into:

1 -- A -- 2 -- B -- 3 -- C -- 4 -- 5
                          \
                           C' -- B' -- A'

$ hg update --clean C
$ hg backout --rev C --message "Backed out changeset: C"
$ hg backout --rev B
$ hg commit --message "Backed out changeset: B"
$ hg backout --rev A
$ hg commit --message "Backed out changeset: A"
$ hg rebase --collapse --source C' --dest 5
$ hg commit --message "Backed out C, B, A"

which will result in the following

1 -- A -- 2 -- B -- 3 -- C -- 4 -- 5 -- C'B'A'

However, backing out in separate branch may result in [logical] conflict in the subsequent merge.

1 -- A -- 2 -- B -- 3 -- X  --  4 
                     \           \
                      B' -- A' -- M

if `X` depends on `A` or `B`, then `M` will have conflict (at least logical conflict).

Problem

Is the most reliable method to go one-by-one, using the backout command for each of many changesets, or is there a way to create one big reversal changeset to cover a whole bunch of [edit: non-contiguous] changesets. If one-by-one, does order matter? (Should one go last-to-first?) Does the best method differ if there are merges among different sub-projects along the way? Does this tend to go smoothly in your experience? :-)

Original source

Related problems