Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I nest subrepos in Mercurial?

I am having trouble setting up a project in Mercurial with subrepos.

Goal:

I want to set up the structure like so:

-- Build_Repo (this repo will be used to track dependencies)
  -- Subrepo_A (this is the main source)
    -- Modules (Part of Subrepo_A)
      -- Subrepo_B 

So there are three repos: Build, A, and B. B is nested inside A, A is nested inside the root build repository. The build repo will be used to track dependencies, subrepo A will be used to track the main source files, and subrepo B (and others) will be used to track module/plugin development.

Problem/Question

I have no problem setting up the initial build repo and the nested Subrepo_A by simply adding the Subrepo_A path and source to the .hgsub file and committing it to the build repo. However, when after I add the subrepo_B path/source to the build repo's .hgsub, and then try to commit I get the error message:

abort: path 'Subrepo_A/Modules/Sebrepo_B' is inside nested repo 'Subrepo_A'

Mercurial doesn't appear to like a nested repo inside an already nested repo. Is this true, or am I missing something? Any better ideas on how to manage builds/dependencies?

like image 868
Craig Smitham Avatar asked Sep 12 '11 22:09

Craig Smitham


1 Answers

The problem here is one of Mercurial's inescapable constraints: a repository corresponds to a folder tree on your computer. The repository is responsible for everything under that folder tree.

When your top-level repository includes a sub-repository, it hands over to the sub-repo complete control of that part of its folder structure. So the top level can't specify another sub-repository somewhere in the first sub-repos folders.

Solution 1

Subrepo_B is actually a dependency of Subrepo_A. In that case, make your repositories reflect the true dependency by editing Subrepo_A's .hgsub file to add Subrepo_B under Modules/Sebrepo_B. This works because Subrepo_A retains control over its folders.

Solution 2

Subrepo_A doesn't depend on Subrepo_B, you were putting it there for convenience. In this case, you should make both Subrepo_A and Subrepo_B be subrepos (in different locations) of the Build_Repo.

like image 163
hcarver Avatar answered Sep 20 '22 22:09

hcarver