使用 Mercurial,我们是否需要“hg merge -r 6880”?是否有额外的分支?

发布于 2024-10-20 16:45:34 字数 580 浏览 3 评论 0原文

对于 Mercurial,现在有 default 分支和 newfeature 分支...如果我在 newfeature 分支,并执行 hg pullhg update,它总是会要求我合并? (如果有我拉取的变更集)

另外,似乎我不能只进行 hg merge ?我需要使用 hg head 然后查看 newfeature 分支的 head 是什么(假设它是修订版 6880), 那么我需要hg merge -r 6880?否则,Mercurial 会自动将 newfeature 分支与 default 分支合并吗?看来我无法执行 hg merge -b newfeature ,因为 hg merge 没有 -b 选项。

除了使用 hg Heads 查找要合并的修订版本之外,还有更简单的方法吗?没有更自动的方法吗?

For Mercurial, right now there is default branch and newfeature branch... is it true that if I am on
the newfeature branch, and do an hg pull and hg update, it will always ask me to merge? (if there are changesets that I pulled)

Also, it seems that I cannot just do hg merge? I need to use hg heads and then look at what the newfeature branch's head is (say it is revision 6880),
then I need to hg merge -r 6880? Because otherwise, will Mercurial merge the newfeature branch with the default branch automatically? I cannot do hg merge -b newfeature, it seems, as there is no -b option for hg merge.

Is there an easier way other than using hg heads to look for the revision to merge? Isn't there a more automatic way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无言温柔 2024-10-27 16:45:34

您有两个问题,让我一次回答一个问题(稍微解释一下):

问。当我hg pull并获得新头时,Mercurial建议我hg merge。我必须这样做吗?

A. 不。Mercurial 只是警告你,你的头比你原来的多,如果你不喜欢这种安排,你可以合并来阻止它。 你会看到警告。

命名的分支是头,所以如果拉动会给你一个新的头Q, 如果我想将一个命名分支合并到另一个分支中,我是否必须提供修订号?

A。不。确实,hg merge 只会自动选择同一命名分支上的头,但您可以执行 hg merge -r newfeature 并从该点合并到变更集中newfeature 上的分歧(在您的示例中为 6880)完全hg update -r 6880 相同。

无论哪种情况,提交合并后,您都不会在 newfeature 上看到任何头(新的结果头位于 default 上,因为这是您之前父级的分支名称)但是,在合并后执行此操作:

hg update newfeature
...code....
hg commit

将在 newfeature 分支上创建一个新头,并且您会回到合并之前的状态,除了所有更改之外。新功能现在也可在默认中使用。

You've got two questions there, let me take them one at a time (with a little paraphrasing):

Q. When I hg pull and get a new head Mercurial suggest I hg merge. Do I have to?

A. No. Mercurial is just warning you you have more heads than than you did, and that if you don't like that arrangement you can merge to stop it. Named branches are heads, so you'll see that warning if pulling gets you a new head

Q. If I want to merge one named branch into another do I have to provide the revision number?

A. No. It's true that hg merge will only automatically select heads on the same named branch, but you can do hg merge -r newfeature and that merges in the changeset from the point of divergence up to the head on newfeature (6880 in your example) exactly the same as hg update -r 6880 would.

In either case, after committing that merge you'll have no heads on newfeature (the new, resulting head is on default because that was the branch name of your parent before you started the merge. However, just doing this after the merge:

hg update newfeature
...code....
hg commit

will create a new head on the newfeature branch, and you're right back as you were before the merge, except all of the changes that were on new feature are also available in default now.

我只土不豪 2024-10-27 16:45:34

如果您将一个或多个变更集从一个分支拉取到共享相同根变更集的另一个分支。正如您所注意到的,Mercurial 将有多个头。它只会建议您在其中一个分支上执行 hg update 时进行合并。

假设您想要合并每个分支的 tips,则不必指定要合并到哪个修订版。 hg merge 应该足够了。

您的命令结构应如下所示

hg pull -b 'branchYouWantToPullFrom`
hg update
hg merge
hg commit

If you pull a changeset or changesets from one branch into another branch that share the same root changeset. Mercurial will have multiple heads as you have so noticed. It will only suggest that you merge when you do an hg update on one of the branches.

You shouldn't have to specify which revision to merge to, assuming that you want to merge the tips of each of the branches. hg merge should suffice.

Your command structure should look as follow

hg pull -b 'branchYouWantToPullFrom`
hg update
hg merge
hg commit
私藏温柔 2024-10-27 16:45:34

hg merge 在您的工作副本中工作,该副本始终连接到特定分支。

仅当您要将当前分支与另一个分支合并时,才必须指定分支名称:hg mergebranch_name

hg pull 使用所有远程更改更新您的存储库。然后您必须更新连接到特定分支的工作副本。因此,当您输入 hg update 命令时,您将使用当前分支中的所有更改来更新工作副本。
如果您想切换到另一个分支,则必须输入 hg updatebranch_name。您可以输入 hgbranch 来了解您当前的分支。

与特定修订版合并的唯一原因是当您有三个或更多头时,这种奇怪的情况可能是由某些 hg Push -f 引起的(非常糟糕的做法)。如果您处于这种情况,了解必须合并哪些修订的正确方法是 hg Heads。在正常情况下,hg Heads 每个分支返回一个头,因此如果您不想,则不必合并不同分支的两个头。

如果您正在一个分支上工作,并且有人在同一分支上提交并推送了一些更改,则您必须在推送之前拉取并合并,只需使用 hg merge,无需修订或分支。

我希望这会对您有所帮助。

hg merge works in your working copy, which is always connected to a specific branch.

You have to specify a branch name only if you want to merge your current branch with another branch: hg merge branch_name.

hg pull updates your repository with all remote changes. Then you have to update your working copy, that is connected to a specific branch. So, when you type hg update command, you update your working copy with all changes in your current branch.
If you want to switch to another branch you have to type hg update branch_name. You can type hg branch to know your current branch.

The only reason to merge with a specific revision is when you have three or more heads, a strange situation probably caused by some hg push -f (extremely bad practice). If you are in this situation, the right way to know which revisions you have to merge is hg heads. In a normal situation hg heads returns one head per branch, so you don't have to merge two heads of different branches if you don't want.

If you're working on a branch and someone has committed and pushed some changes on the same branch, you have to pull and merge before your push, simply with hg merge, no revision or branch.

I hope this will help you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文