hering
hering

Reputation: 1954

Using subrepositories in mercurial to "share code"

I have a repository in which I have three subfolders.
A, B and a core folder.

I need the files of the core folder in A and in B. So every file of the core folder should be inside another folder in A and B and every update to the files should be commited to "core" and vice versa.
So I tried to make the core folder to a subrepository and add this to A and B.

So in folder B for example there is following line in the .hgsub www = ../core
In the main repository is in the .hgsub core = core

I assume there is something I do wrong, but maybe you have a hint how to achieve what I want :)

(Update)
To clarify:
The repository contains different "projects" for an app.
A is Android and B is iOS. The "core" contains HTML+JS files which are later used in the Android and iOS projects to build apps with phonegap.

Upvotes: 2

Views: 398

Answers (1)

Lasse V. Karlsen
Lasse V. Karlsen

Reputation: 391336

If I understand you right, you have this:

repo
  |
  +-- core         <--+
  +-- A               |
      +-- core     ---+ \A\core and \B\core should be equal to \core
  +-- B               |
      +-- core     ---+

There is nothing in Mercurial that will help you with this.

What you can do is this:

core-repo
  +-- (content)

repo
  +-- A
      +-- core        --- sub-repo pointing to core-repo
  +-- B
      +-- core        --- sub-repo pointing to core-repo

This will allow you to commit changes to the sub-repo inside A, push, and then pull and update into the sub-repo inside B, keeping them in sync.

Upvotes: 8

Related Questions