简体   繁体   English

如何在mercurial中“进一步拆分”?

[英]How can I “split the branch further” in mercurial?

Admittedly a misleading title, but I didn't know how to put it better. 不可否认,这是一个误导性的标题,但我不知道如何把它变得更好。

So I made the mistake of pushing all my project specific changes BEFORE I opened a branch. 因此,在开设分支之前,我错误地推动了所有项目特定的更改。 That way, there are some changeset sitting in the default branch that does not belong there. 这样,有一些变更集位于默认分支中,不属于那里。 They should be in my newly opened branch. 他们应该在我新开的分店。

Do I have to backout all the changesets first and then push them again to the correct branch? 我是否必须先退出所有变更集,然后再将它们推送到正确的分支机构? Does that even work? 这甚至有用吗?

Thank you for your help. 谢谢您的帮助。

Without resorting to EditingHistory (which is generally advised agains, and is certainly in opposition to the mercurial "immutable history" design goals) those changes will be in your history forever. 如果不采用EditingHistory(通常会再次建议,并且肯定与多变的“不可变历史”设计目标相对立),这些变化将永远存在于您的历史中。 You can, however, undo them in your 'tip' revision and then trickle them back in multiple subsequent changesets spread over multiple branches. 但是,您可以在“提示”修订版中撤消它们,然后在分布在多个分支上的多个后续更改集中将它们涓涓细流。

Let's imagine this is your current history: 让我们假设这是您当前的历史:

[R0] -> [R1] -> [R2] -> [R3]

Where revisions R2 and R3 have some stuff you wanted in the default branch and some stuff you wish was in a different branch. 修订版R2和R3在默认分支中有你想要的东西,你想要的东西在不同的分支中。 You can create a new revision, R4, that undoes R2 and R3. 您可以创建一个新版本R4,它可以撤消R2和R3。 That can be done using backout as you suggest, or since you're doing multiple changesets, perhaps more easily using 'revert'. 这可以使用你建议的退出来完成,或者因为你正在做多个变更集,也许更容易使用'revert'。

hg update tip ; hg revert --all -r R2 ; hg commit -m 'undid changes R2 and R3'

then your history will look like this: 那么你的历史将如下所示:

[R0] -> [R1] -> [R2] -> [R3] -> [R4]

then you can split your work into the changesets you wish you'd initially done, yielding a history like this: 然后你可以将你的工作分成你希望你最初完成的变更集,产生这样的历史记录:

[R0] -> [R1] -> [R2] -> [R3] -> [R4] -> [R5] -> [R7]
                                   \
                                    --> [R6] -> [R8]

R6 and R8 can be on the branch named 'default' or on a different named branch. R6和R8可以位于名为“default”的分支上,也可以位于不同的命名分支上。 Either way, you can push just R0 through R5 and R7 by doing: 无论哪种方式,你可以通过以下方式将R0推到R5和R7:

hg push -r R7

That works because a push pushes a revision and all of its ancestors -- but R6 and R8 aren't ancestors of R7, so they won't get pushed no matter what branch they're on. 这是有效的,因为推动修正及其所有祖先 - 但R6和R8不是R7的祖先,所以无论它们在哪个分支上它们都不会被推动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM