Mercurial中的父子项目关系 [英] parent/child project relationship in Mercurial

查看:81
本文介绍了Mercurial中的父子项目关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不熟悉Merurial(一般来说不包括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 ?

推荐答案

我认为,如果您四处寻找供应商分支"的答案,也会发现它们也能解决您的问题.

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]

使用类似这样的存储库,您对子集进行的任何更改都可以轻松地hg pull分为superset1和/或superset2.例如,如果您在子集中添加了新功能,则您的回购现在可能看起来像这样:

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]

并将它们放入superset1和superset2中后,您将拥有:

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]

然后您只需在superset1和superset2中hg merge即可获得:

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]--

从超集1到超集2或从任一超集到子集的更改都不太干净,因此在子集中进行更改并将其拉入/合并到超集中,就可以了.

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.

这篇关于Mercurial中的父子项目关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆