简体   繁体   English

在Mercurial中,有没有办法(除了“Cherry pick”之外)推动变更集而不推动与不同头部相关的变更集?

[英]In Mercurial, is there any way (aside from “Cherry picking”) to push a changeset without also pushing changesets associated with a different head?

In the answer to this question , Ry4an states that "you cannot push Changeset2 without pushing Changeset1". 这个问题的答案中, Ry4an声称“你不能在不推动Changeset1的情况下推动Changeset2”。

This certainly makes sense if the repository looks like this: 如果存储库看起来像这样,这当然有意义:

+ Changeset2
|
+ Changeset1
|
+ Original

However it doesn't seem to make as much sense in the following scenario, which is what I currently have: 然而,在以下场景中似乎没有那么多意义,这是我目前所拥有的:

+ Changeset2
|
|   + Changeset1
|  /
| /
+ Original

Ideally, I want to be able to push just Changeset2 back to the repository I initially cloned from. 理想情况下,我希望能够将Changeset2推送回我最初克隆的存储库。 Mercurial doesn't seem willing to let me do that. Mercurial似乎不愿意让我这样做。 It's insisting I push Changeset 1 also... which is not allowed as it would create a new head in the original repository. 它坚持我也推动Changeset 1 ......这是不允许的,因为它会在原始存储库中创建一个新头。 Obviously I could "Cherry pick", or create a patch to apply on the original repository but that seems clunky. 显然我可以“Cherry pick”,或者创建一个补丁来应用于原始存储库,但这看起来很笨拙。 Am I missing something? 我错过了什么吗?

Update: I should probably have mentioned in my initial question that I was trying to perform the operation from the TortoiseHg GUI. 更新:我可能在我最初的问题中提到我试图从TortoiseHg GUI执行操作。 As Niall C . 作为Niall C. correctly identified in his answer, the Mercurial command line allowed me to accomplish what I needed, however I would still be interested in learning if there is any way to accomplish the same operation from the GUI. 在他的回答中正确地指出,Mercurial命令行允许我完成我所需要的,但是我仍然有兴趣学习是否有任何方法可以从GUI完成相同的操作。

If you're using hg push without any command-line option, it will try to push every changeset in your local repository that doesn't exist in the remote repository. 如果你在没有任何命令行选项的情况下使用hg push ,它将尝试推送本地存储库中远程存储库中不存在的每个变更集。 If you use the -r / --rev option, it will just push that revision and its ancestors. 如果使用-r / --rev选项,它将只推送该修订版及其祖先。 In your case, you would need to do: 在您的情况下,您需要做:

hg push --rev Changeset2

See hg help push for full details. 有关详细信息,请参阅hg help push

For the UI lovers who like pictures: 对于喜欢图片的UI爱好者:

  1. In TortoiseHg click on Detect outgoing changes to button. 在TortoiseHg中,单击“ Detect outgoing changes to按钮。 在此输入图像描述

  2. Click right mouse button on revision you want to push. 在要推送的修订版上单击鼠标右键。

  3. Choose Push -> Push to Here . 选择Push -> Push to Here 在此输入图像描述

Result: You will push only revision selected rather than everything. 结果:您将仅推送选定的版本而不是所有内容。 在此输入图像描述

Hope this saves you some time. 希望这能为您节省一些时间。

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

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