parent/child project relationship in Mercurial

左心房为你撑大大i 提交于 2019-12-24 16:48:52

问题


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 ?


回答1:


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.



来源:https://stackoverflow.com/questions/5510671/parent-child-project-relationship-in-mercurial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!