Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial repo inside a repo

Is it possible to create a mercurial repository inside an existing mercurial repository?

The idea is to handle subdirectories of a repository as different repositories, how do you do that?

I'm not talking about subrepos (at least, if I understood the purpose of subrepos...), but if this is how subrepos do exist for, I got it wrong and I'll try to get it right :)

Thanks ~Aki

EDIT: To be more clear, I'd like to know what happens, the practices and the implications of having a repository inside another one, without specifying modules/subrepos. In other words: what happens if I just do:

hg init globalRepo
hg init globalRepo/subRepo

and use these two repositories as-are?

like image 703
AkiRoss Avatar asked Jun 12 '10 13:06

AkiRoss


2 Answers

It works well. Long before the subrepo support was added in Mercurial 1.3, lots of folks kept their entire home directories in a mercurial repo for tracking their .bashrc files and the like. Then within their home dir they'd have many clones of other repos.

Whenever you invoke mercurial (without the -R option) it looks in the current directory for a .hg directory and then just keeps going up directories until it finds one. So if you're in a repo that is in a repo, your commands will always act on the innermost repo you're in.

The caveat is that you want to make sure not to have files added to the outer repo that end up inside the inner repo. Then you'll have two repos updating the same files.

like image 153
Ry4an Brase Avatar answered Sep 24 '22 23:09

Ry4an Brase


As you can see in this SO question, you can make that kind of nested hg init, even though it is usually reserved for defining subRepo (which is not what you are after).

Normally it should work as two independant repos, but I would advise adding an hgignore rule in the globalRepo in order to ignore the subRepo content altogether.

like image 29
VonC Avatar answered Sep 21 '22 23:09

VonC