Why doesn't the Mercurial strip command rewrite history?

The Mercurial help text says that the strip command deletes the specified changes and all their descendants. "This is very similar to rewriting the history for me and that this should cause problems if someone bases their work on one of the sets of changes that are suddenly deleted But the help text also says that the command “is not a rewriting of history and can be used in changesets in the public phase.” I’m sure that the person who wrote the help text knew very well what he was doing, so what I’m missing to understand this ?

+6
source share
2 answers

The key point is that if you delete a public set of changes and then pull it out from somewhere, you are not causing any problems. You will simply return the original set of changes.

If you (for example) bring down two common sets of changes together, and then pull the original from somewhere, now you have two branches. One with the original two sets of changes and one with a collapsed set of changes, but both have the same changes. At that moment, hell breaks and the children eat monsters roaming the earth.

Therefore, rewriting history is not the same as deleting history.


davidmc24 pointed out this post by Matt McCall (Mercurial father), in which he says basically the same thing

+7
source

I can’t say it with certainty, but I guess it’s "grandfathered in". hg strip began as part of mq , preceding the addition of phases for at least three years.

Probably the best phrase:

not considered * an operation of rewriting history and can be used in sets of changes in the public phase

When the steps were added, great care was taken not to disrupt any existing workflow. Obligations begin at the project stage and become publicly available after they are pressed. Any commands that support the phase know that after clicking the commit phase it is public and does not allow modification if it is (unless push was in the repository that is not the publisher ...).

However, there were people who already used strip manually, and in the scripts, they deleted the change sets that were pressed, and if strip after the update suddenly said: “Hey, you can’t ban it publicly!” then these people would have a broken promise of compatibility.

The phases are gradually turning into a rather amazing evolve system, which will be a much better choice than mq for almost all cases, but I still doubt we will ever take Matt to remove mq and strip - he still insists on keeping it compatible with Python 2.4 and 9 years old!

Tl; Dr: Despite the fact that strip has always been a disabled extension, too many people use it to change its behavior with the advent of phases.

+1
source

All Articles