How to return multiple commits in Mercurial?

I have a bunch of commits like A, B, C, D, and I want to save B, C and D and make a commit (BCD) ⁻¹. What is the easiest way to do this if I have many commits that I want to cancel at the same time?

(It seems to me that it seems to me that the question arises that I have hg update equal to A and then call hg commit with some arguments, but now I can not find this question.)

+6
source share
3 answers

It looks like you are looking for a backout . Cm:

 hg help backout 

I don’t think it can cancel multiple commits at a time, so you need to cancel them yourself:

 hg backout D hg backout C hg backout B 

This will create three commits on top of D that are facing D, and C and B. If you want to combine these commits into one set of changes, you can add them using rebase --collapse or one of several other extensions (for example, histedit or mq or collapse ).

If you do not want to undo individual changes, but all this at a time, you can do the following:

 hg update A hg debugsetparents D hg commit -m "revert BD" 

Its ugly, but it works. However, this does not write renames in reverse order. Honestly, I would not recommend doing this if you need to drop it so much that the individual retraction commands are too complex to print, makes me wonder if what you should really do in this particular case.

Alternatively, you could do what Jim and Raphael suggested and decide that B, C, and D are on a branch and upgrade to A and continue to do there (turning off the story at this point). This may be more appropriate.

+4
source

The easiest way:

You are in change set D and want to complete this branch

 hg commit --close-branch -m "Branch closed" 

Now just go into change set A and continue your work by doing new things.

 hg up -r A ... change stuff ... hg ci -m "New stuff" 

The branch that has B, C and D will be there, but it will be completed, it will not be displayed in hg heads . This will be an inactive branch.

It is easy to do and expressive. If you look at the chart, you will see a separate branch that has been closed, and the “official” branch will continue. Much better than those that revert and restore changes, creating noise in your branch.

+4
source

You answered your question, upgrade to A and just continue from there. If you need to create a new head at this moment, you need to make changes to some file or another, as described here: How to force force mercury to be accepted for an empty commit . A mail flow associated with this post describes how to use MqExtension to remove a BCD (if you haven't clicked):

+1
source

Source: https://habr.com/ru/post/921100/


All Articles