1

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 ?

Rafael Munitić
  • 897
  • 2
  • 9
  • 21

1 Answers1

2

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.

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
  • For the record this isn't using 'named branches' at all. Just normal changeset parentage on the 'default' branch, which is a great way to go. – Ry4an Brase Apr 01 '11 at 16:28
  • This pretty much confirms what I thought would be necessary but I also figured that puling the changes up to super is not a simple/clean process which is kind of what I was hoping to get. But it's seems the only way to do so i'll keep two repos and move changes from Super->Sub. I'm accepting the answer, tnx. – Rafael Munitić Apr 01 '11 at 21:41
  • You can do super to sub, you'll just end up using export+import (aka transplant) which means the same change will exist with 2 different hashids and you'll get it twice in super when you pull from sub back to super. It'll work fine, just look a little odd. Best to go sub to super when convenient. – Ry4an Brase Apr 02 '11 at 02:51