Mercurial 仅合并某些变更集

发布于 2024-08-28 05:32:52 字数 503 浏览 8 评论 0原文

好的,我们最近从 SVN 转换为 Mercurial。
我们正常使用TortoiseHG。

在我们的一个存储库中,我们拥有所有项目,C++ / .NET / ASP。我们有大约 100 个项目,全部使用公共库项目。

因此,为每个项目创建多个存储库将是一项非常困难的任务。

现在,我们有了 default 分支,假设是 branchA
我正在开发 BranchA 并向其添加我的超级更改,并且我更改了一个公共库,比方说一个扩展方法

我想将其提交给 branchAdefault,我该怎么办?

但是,我不希望将 branchA 中的所有更改合并到 default 中,并且我不希望 default 中的所有其他更改

希望这是足够的信息!

Ok, so we recently converted from SVN to Mercurial.
We are using TortoiseHG normally.

In our one repository we have all of our projects, C++ / .NET / ASP. We have about 100 projects, all using common library projects.

So it would be quite difficult task to create multiple repo's for each project.


Now, we have the default branch, and let's say branchA.
I'm working on BranchA and adding my uber changes to it, and I change a common library, let's say an extension method

I want to commit this to branchA and default, how would I go about this?

However, I don't want all my changes from branchA to be merged into default, and I don't want all the other changes from default

Hopefully this is sufficient information!

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

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

发布评论

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

评论(5

魂ガ小子 2024-09-04 05:32:52

只是为了保持更新:有 graft 命令 实现在 Mercurial 中挑选樱桃。

此命令使用 Mercurial 的合并逻辑来复制各个更改
来自其他分支,而不合并历史图中的分支。
这有时被称为“向后移植”或“挑选樱桃”。经过
默认情况下,graft 将从源复制用户、日期和描述
变更集。

Just to keep things a bit updated: there is the graft command which implements cherry-picking in Mercurial.

This command uses Mercurial's merge logic to copy individual changes
from other branches without merging branches in the history graph.
This is sometimes known as 'backporting' or 'cherry-picking'. By
default, graft will copy user, date, and description from the source
changesets.

还给你自由 2024-09-04 05:32:52

有一种方法可以避免这个问题。您可以在某些基线修订版的单独功能分支上进行所有更改,通常是最后一个版本的标签或其他一些稳定点S

这样,您的更改 X 将位于其自己的分支上,该分支可以与其他分支合并(合并 M1M2),而不会引入不需要的变更集:

-----S--o----o---M1----o---> default
     |          /
     |---------X   feature or bugfix
     |          \
     \--o---o----M2----o-----> BranchA 

这只需要正常的 hg merge 操作;无需补丁,移植MQ

There is a way to avoid this problem. You can make all your changes on separate feature branches from some baseline revision, typically the tag of the last release or some other stable point S.

That way, your change X will be on its own branch which can be merged with other branches (merges M1 and M2) without introducing unwanted changesets:

-----S--o----o---M1----o---> default
     |          /
     |---------X   feature or bugfix
     |          \
     \--o---o----M2----o-----> BranchA 

This only requires normal hg merge operations; no need for patches, Transplant or MQ.

隐诗 2024-09-04 05:32:52

如果将公共代码分离到自己的存储库中,则可以使用子存储库将其包含在每个项目中。

顺便说一句,我建议为每个项目都有一个单独的存储库,尤其是在项目数量很多的情况下。

If you separate the common code into its own repository, you can use subrepos to include it in each project.

By the way, I would recommend to have a separate repository for each project, especially if there are so many.

单身狗的梦 2024-09-04 05:32:52

想要的不是合并,而是择优挑选。您可以使用 https://www.mercurial-scm.org/wiki/TransplantExtension ,但请注意那里提到的并发症。

What is want is not merge, but cherry-pick. You can use https://www.mercurial-scm.org/wiki/TransplantExtension, but be aware about complications mentioned there.

半窗疏影 2024-09-04 05:32:52

您正在描述“樱桃采摘”或进行“部分合并”,这目前在 Mercurial 中是不可能的。您有几个选择:

  • 将公共代码分离到其自己的存储库中。
  • 生成对公共代码所做的更改的差异,并将其应用到 default 分支。

You're describing "cherry picking" or doing a "partial merge" which isn't possible with Mercurial currently. You have a few options:

  • Separate your common code into its own repository.
  • Generate a diff of your changes that you made to your common code, and apply that to the default branch.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文