0

My repository A depends on repository B, so I intend to add B to A as a subrepo. But in fact, A doesn't depend on all of B, just, say on the contents of a subfolder bar/ in the root of the B repository.

Is it possible to indicate that just the subfolder constitutes the subrepo?

Note: This is essentially the same question as

Git Submodule to a subfolder

but for mercurial rather than git.

Community
  • 1
  • 1
einpoklum
  • 118,144
  • 57
  • 340
  • 684

1 Answers1

1

The same answer holds true for mercurial: You cannot make a checkout which contains only part of a repository.

If you need only part of a repository, you can consider the same approach and move the part which is of wider interest (e.g. a library) into a separate repository which henceforth can be referenced as sub-repo by several proejcts. However you should consider whether you really want it an official sub-repository or if you simply link it (without making it an official sub-repository); you could also split-out that library part into a separate repo and regularily simply pull that into the repositories which shall make use of it (which is a duplication of sorts, but avoids the sub-repo approach).

planetmaker
  • 5,884
  • 3
  • 28
  • 37
  • I actually wish you could just pull multiple repositories onto each other, and that would solve the concrete issue I'm having. But that's beyond the scope of this question. – einpoklum Apr 03 '17 at 21:03
  • 1
    You can simply pull from any repository you like. Mercurial will tell you that it's unrelated and ask you whether you want to proceed, if there's no common history. But you can just do that. – planetmaker Apr 03 '17 at 22:05
  • I don't know that I can have multiple repositories in the exact same folder (not in subfolders). Am I wrong? – einpoklum Apr 03 '17 at 22:25
  • 1
    You cannot have several repositories. But you can pull from several unrelated repository into one repository - which will give you a repository with several initial revisions which you need to merge to obtain a revision which contains everything you need and want. – planetmaker Apr 03 '17 at 23:05