我是 Mercurial 的新手,我读到不可能仅合并来自另一个分支的单独变更集。
然后我不知道解决这个问题的最佳方法是什么:
- 我从稳定版本 R1 开始
- 我继续在 R1 上开发:CS1,CS2,CS3
- 在某些时候我需要解决稳定版本 R1 中的错误。我只想应用开发线(fe CS2)中的一个变更集,
最好的方法是什么?由于合并不起作用,我所做的就是制作 CS2 补丁,然后在新的稳定分支中应用该补丁来修复错误。这就是水星的方式吗?
干杯,
I'm new to mercurial and I read that it's not possible to merge only a separate changeset from another branch.
Then I don't know what's the best approach to solve that:
- I start with an stable revision R1
- I continue developing on R1: CS1,CS2,CS3
- At some point I need to solve bug from my stable revision R1. And I want to apply only one changeset from developing line (fe CS2)
What's the best aproach? As merging didn't work what I've done is make a patch of CS2 and then apply the patch in the new stable branch to fix the bug. That's the Mercurial way?
Cheers,
发布评论
评论(2)
更新:从 Hg 2.0 开始不再需要任何扩展
正如“CAD 家伙”所指出的,这正是 graft 命令是在 Hg 2.0 中引入的。
SourceTree
最简单的方法是使用像 SourceTree 这样的 GUI,只需双击- 单击要切换的 TARGET 分支,然后在任何其他修订上按鼠标右键并选择“移植”命令(奇怪的是它也可以是当前分支的修订)。
如果没有冲突,SourceTree 将立即为当前分支创建一个新版本。
TortoiseHg
完全一样,选择TARGET Branch,然后在要嫁接的修订版上人民币:如何使用 TortoiseHg 进行移植
命令行
要使用命令行执行此操作,只需切换到 TARGET 分支,然后
执行{revision_number} 显然是您要合并到当前分支中的修订版本号。这将在您当前的分支中创建一个新的变更集,其中包含您在命令中使用的修订版本中的所有文件。
要了解有关移植命令的更多信息,请阅读 stackoverflow 上的此线程
UPDATE: No need for any extension anymore as of Hg 2.0
As 'CAD bloke' pointed out, this is exactly what the graft command is for which was introduced in Hg 2.0.
SourceTree
The easiest way to do this is with a GUI like SourceTree, just double-click on the TARGET branch to switch, then press the right mouse button on any other revision and select the 'Graft' command (strangely it can also be a revision of the current branch).
If there are no conflicts SourceTree will immediately create a new revision for the current branch.
TortoiseHg
Exactly the same, select TARGET Branch, then rmb over the revision you want to graft: How to graft with TortoiseHg
Command Line
To do this with the command line just switch to the TARGET branch and then execute
with {revision_number} obviously being the number of the revision you want to incorporate into you current branch. This will create a new changeset in you current branch with all the files from the revision whose number you used in the command.
To find out more about the graft command read this thread here on stackoverflow
移植扩展可自动执行单个命令的操作。
但我认为首选方法(根据情况并不总是可行)是首先在 R1 之上进行修复,然后将其合并到您的开发技巧中。
即:
R1
开始。cs1...csN
。R1
之上保持稳定,需要进行重要修复,因此您hg 更新 R1
。R2
。hg update csN
。hg merge R2
,hg commit
...csN+1
。The transplant extension automates what you've done to a single command.
But I think the preferred way (which depending on the scenario isn't always possible) is to make the fix on top of
R1
in the first place, and then merge that to your development tip.That is:
R1
.cs1...csN
.R1
, so youhg update R1
.R2
.hg update csN
.hg merge R2
,hg commit
...csN+1
.