开发者

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开发者_JS百科 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?


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.


In your situation, you'll have to add subrepoB to subrepoA.

I would suggest trying to move dependencies so that your tree only has 2 levels, but that may not be possible. It's always not a very smooth experience otherwise.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜