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

前端 未结 5 765
Happy的楠姐
Happy的楠姐 2021-02-13 01:33

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 bunc

5条回答
  •  礼貌的吻别
    2021-02-13 02:21

    If you have no merges along the way, you can either back out every individual change (in reverse order), or, if there are many of them, do it with one big inverse patch.

    If you have good changesets atop the ones you need to back out, better commit the inverse patch on top of the most recent bad changeset, then rebasing them onto the tip of the branch.

    1 -- 2 -- A -- B -- C -- 3 -- 4
                         \
                          C'B'A'
    
    $ hg up C
    $ hg diff -r C:2 > backout.diff
    $ hg import --no-commit backout.diff
    $ hg ci -m "Backout A, B, C"
    $ hg up 4
    $ hg rebase -s C'B'A -d .
    

    There will be problems if you want to back out merge changesets, see this wiki page for more information.

    In such a case, if possible, consider re-doing the branch and stripping the old lineage. Otherwise, you might have to abandon the branch altogether, salvaging the good changesets via graft or transplant.

提交回复
热议问题