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

前端 未结 5 776
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条回答
  •  旧时难觅i
    2021-02-13 02:05

    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).

提交回复
热议问题