In mercurial, how do I apply a reverse-patch to a particular file?

前端 未结 3 1528
感情败类
感情败类 2021-02-04 02:24

Related to Mercurial: Merging one file between branches in one repo , I\'m trying to perform a backout operation on a single file, even though that file was one of many particip

3条回答
  •  悲哀的现实
    2021-02-04 03:16

    Here's what I would do: Use a fresh clone of the tip revision.

    hg backout --merge -r revision_where_the_change_happened
    

    to merge the reversed changes into the working copy.

    Now copy the file in question to your regular working copy and commit

    hg commit -m "Reversed the changes to file.h made in revision bla"
    

    and throw away the clone you created above.

    This way, mercurial doesn't know that there is a connection between revision_where_the_change_happened and this commit. If you want mercurial to remember this, instead do a

    hg revert {all files except the one in question}
    

    after merging the backout commit into the working copy and before commiting. For the second way, you don't need to work on a clone, because you want to keep the backout commit.

    I would guess that the choice of which way you use depends on how big a part of the changeset the particular file change was.

提交回复
热议问题