views:

280

answers:

4

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?

+2  A: 

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

:-)

Oatman
A: 

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.

msw
?! I'm under the impression that mercurial automatically ignores other mercurial directories underneath its root hierarchy. (having actually done this)
Jason S
Correct you are: it does ignore subordinates. However given mercurial's default terse output, I still maintain you'd be buying yourself confusion.
msw
+1  A: 

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'
kriss
+1  A: 

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: http://mercurial.selenic.com/wiki/subrepos

Also, there is an extension named "forest" that might become obsolete in the future: htt p://mercurial.selenic.com/wiki/ForestExtension

mercurial_needs_this_feature