Mercurial 中的父/子项目关系

发布于 2024-10-29 11:25:55 字数 251 浏览 2 评论 0原文

我是 Mercurial(以及一般的 SCM)的新手,并且我一直致力于处理两个项目之间的父子关系。一个项目是父项目,并且是另一个项目的子集(或者更确切地说,另一个项目是第一个项目的超集)。我想在一个本地存储库中处理这两个项目,就像它们是一个一样,但我想将它们发布到两个不同的公共存储库。

我查看了子存储库,但这不是我想要的,因为我需要我的存储库在同一根目录上工作。我的猜测是使用分支,但将更改合并到超级项目中不需要添加新文件吗?

最简单/正确的方法是什么?

I'm new to mercurial (and SCM in general) and I'm stuck at handling a parent child relationship between my two projects. One project is the parent project and is a subset of the other project (or rather, the other one is a superset of the first). I want to work on the two projects in a single local repository as if they were one but I want to publish them to two different public repositories.

I've looked at sub-repositories but that's not what I want since I need my repositories to work on same root directory. My guess would be to use branching but wouldn't merging the changes in to the super-project require the addition of new files ?

What would be the simplest/correct way to do this ?

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

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

发布评论

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

评论(1

微暖i 2024-11-05 11:25:55

我想,如果您四处寻找“供应商分支”的答案,您会发现它们也涵盖了您的情况。

基本要点是确保您想要保留的任何更改都是子集存储库来自该子集的更改集作为祖先。这是一个粗略的图片:

subset:

[A]---[B]----[C]----[D]

superset1:

[A]---[B]----[C]----[D]---[E]---[F]


superset2:

[A]---[B]----[C]----[D]---[G]---[H]

使用这样的存储库,您在子集中所做的任何更改都可以轻松hg pull到 superset1 和/或 superset2 中。例如,如果您在子集中添加新功能,您的存储库现在可能如下所示:

subset:

[A]---[B]----[C]----[D]---[I]---[J]

superset1:

[A]---[B]----[C]----[D]---[E]---[F]


superset2:

[A]---[B]----[C]----[D]---[G]---[H]

将它们拉入 superset1 和 superset2 后,您将拥有:

subset:

[A]---[B]----[C]----[D]---[I]---[J]

superset1:

[A]---[B]----[C]----[D]---[E]---[F]
                       \
                        --[I]---[J]

superset2:

[A]---[B]----[C]----[D]---[G]---[H]
                       \
                        --[I]---[J]

然后您只需在 superset1 中 hg merge和 superset2 得到:

subset:

[A]---[B]----[C]----[D]---[I]---[J]

superset1:

[A]---[B]----[C]----[D]---[E]---[F]---[K]
                       \             /
                        --[I]---[J]--

superset2:

[A]---[B]----[C]----[D]---[G]---[H]---[L]
                       \             /
                        --[I]---[J]--

将更改从 superset1 移动到 superset2 或从任一超集移动到子集不太干净,因此在子集中进行更改并将其拉出/合并到超集中,然后就可以开始了。

I think if you look around for 'vendor branch' answers you'll find they cover your case too.

The basic jist is to make sure that any change you want to stay is the subset repository has only changesets from that subset as ancestors. Here's a crude picture:

subset:

[A]---[B]----[C]----[D]

superset1:

[A]---[B]----[C]----[D]---[E]---[F]


superset2:

[A]---[B]----[C]----[D]---[G]---[H]

With repositories like that any change you make in subset can be easily hg pulled into superset1 and/or superset2. If, for example, you add a new feature in subset your repos might now look like this:

subset:

[A]---[B]----[C]----[D]---[I]---[J]

superset1:

[A]---[B]----[C]----[D]---[E]---[F]


superset2:

[A]---[B]----[C]----[D]---[G]---[H]

and after pulling those into superset1 and superset2 you'd have:

subset:

[A]---[B]----[C]----[D]---[I]---[J]

superset1:

[A]---[B]----[C]----[D]---[E]---[F]
                       \
                        --[I]---[J]

superset2:

[A]---[B]----[C]----[D]---[G]---[H]
                       \
                        --[I]---[J]

and then you'd just hg merge in superset1 and superset2 to get:

subset:

[A]---[B]----[C]----[D]---[I]---[J]

superset1:

[A]---[B]----[C]----[D]---[E]---[F]---[K]
                       \             /
                        --[I]---[J]--

superset2:

[A]---[B]----[C]----[D]---[G]---[H]---[L]
                       \             /
                        --[I]---[J]--

Moving changes from superset1 to superset2 or from either superset to the subset is much less clean, so make the change in the subset and pull/merge it into the supersets and you're good to go.

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