Can one Mercurial repository live inside another Mercurial repository?
Asked Answered
N

4

8

Can one hg repo live inside another hg repo on my local file system?

screenshot of one repo inside another

I am pulling down the bitbucket wiki for 'sandbox', and I want to know if this should be placed in repos/sandbox/wiki or repos/sandbox-wiki.

Is the former okay to do?

Edit: See Subrepository.

Neutrality answered 20/5, 2010 at 13:16 Comment(0)
R
5

Yes and no. Depends on what you want to do. You can create repo 'sandbox/wiki' but files in this inner repos won't be commited in the outer 'sandbox' repo (@Jason is right). If you don't want to, no problem.

Try explicitly adding files from wiki repos in sandox and you'll get the message below. If you just add path to some directory containing an inner repo the files will just be ignored.

From sandox root directoy:

   hg add wiki/myfile
   abort: path 'wiki/myfile' is inside repo 'wiki'
Risotto answered 20/5, 2010 at 13:54 Comment(0)
T
7

The short answer is yes, but I can't imagine why you would want to.

In your example, I think you should go with:

repos/sandbox-wiki

[edit] Additionaly:

Yo Dowg, I herd you like repositories.

So we put a repo in your repo so you can version while you version

:-)

Thomasina answered 20/5, 2010 at 13:19 Comment(0)
R
5

Yes and no. Depends on what you want to do. You can create repo 'sandbox/wiki' but files in this inner repos won't be commited in the outer 'sandbox' repo (@Jason is right). If you don't want to, no problem.

Try explicitly adding files from wiki repos in sandox and you'll get the message below. If you just add path to some directory containing an inner repo the files will just be ignored.

From sandox root directoy:

   hg add wiki/myfile
   abort: path 'wiki/myfile' is inside repo 'wiki'
Risotto answered 20/5, 2010 at 13:54 Comment(0)
O
1

Mercurial does not allow nested repositories, but there is at least one reason for them:

Imagine that you are working in a project: /MyProject. In this folder you put everything: code, documentation, tests, etc.

You want to backup your work because it is very important, so you create a repository for /MyProject. Then, overtime you use bundles to save the evolution of /MyProject and back up them in a USB flash memory so that you can recover everything just in case your hard drive breaks.

Remember that /MyProject contains everything. And among all those things, there are the main code and some auxiliary projects. You also want to track the progress of an auxiliary project that is in /MyProject/AuxiliaryProject, so you use Mercurial to track its evolution.

Also, you want to have a separate repository for the main code: /MyProject/Main

In this situation you want nested repositories: one big one for being able to back-up everything using bundles and child repositories for managing each subproject.

I think Mercurial should give the user several options when initializing a repository. For example: - ignore nested repositories - include nested repositories but ignoring .Hg folders (i.e. act as if there were no nested repositories but do not ignore the information contained in the nested respositories). - include nested repositories and also include .Hg folders (makes sense for back-up purposes)

--------- Edit: Subrepositories is a feature that is work in progress: https://www.mercurial-scm.org/wiki/subrepos

Also, there is an extension named "forest" that might become obsolete in the future: https://www.mercurial-scm.org/ForestExtension

Onward answered 28/6, 2010 at 12:7 Comment(0)
O
-1

You'd need to set up an .hgignore file in sandbox to exclude wiki because mercurial assumes that it is responsible for all descendants. This would probably generate more user confusion than it is worth.

Ormolu answered 20/5, 2010 at 13:21 Comment(2)
?! I'm under the impression that mercurial automatically ignores other mercurial directories underneath its root hierarchy. (having actually done this)Iodometry
Correct you are: it does ignore subordinates. However given mercurial's default terse output, I still maintain you'd be buying yourself confusion.Ormolu

© 2022 - 2024 — McMap. All rights reserved.