Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I have a web app thats been in active development for about 8 months now and its becoming apparent that the project has a need to maintain a separation between app specific code and our OO Javascript API.

What I would like to do is have another repository with the following general structure of the js API code.


Of course this structure is different from the original web app directory structure. If I make changes to this new repository how could I pull in those changes to the web app repository without unintentionally removing files or modifying the directory structure of the web app repository?

share|improve this question

closed as off-topic by gnat, MichaelT, Bart van Ingen Schenau, GlenH7, Robert Harvey Dec 5 '13 at 18:50

  • This question does not appear to be about software development within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

This question appears to be off-topic because it is tour programming tools - would belong to Stack Overflow, but is too old to migrate –  gnat Dec 4 '13 at 15:49

1 Answer 1

It sounds to me like you're in need of a sub-repository. This will allow you to have a main repo but extract out a selection of your main project into it's own repository (which you can work on independently of the main project, or as a nested repo).

Subrepositories let you treat a collection of repositories as a group. For example, when you clone a repo, Mercurial will recursively clone all of its subrepositories as well, so the developer (or build server) doesn’t need to know about the dependencies — the source control system handles it all.

When you create (or update) a subrepository, Mercurial takes a snapshot of the subrepo’s state and stores it in the parent repository’s .hgsubstate file. This means that multiple projects can point to a single shared subrepository, yet each one can independently decide which revision of the shared repository to rely on.

Further, the subrepository can be anywhere — on your local disk, in Kiln, on a co-worker’s machine, etc. Heck, it can even be a Subversion repository!

Some links I found useful when creating subrepositories are:

  1. Using Mercurial SubRepositories
  2. Convert a folder into a subrepository
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.