tags:

views:

65

answers:

2

What happens if there is already a Mercurial repository at

/User/peter/development

and now I want to add a repository for

/User/peter

because I also want to version .bashrc, .profile, or maybe /User/peter/notes as well. Will having a repository above an already existing repository create conflicts for Mercurial?

+3  A: 

Everything will be okay.

It seems that Mercurial is smart enough to ignore subdirectories which already have repositories in them. Here's a conversation with it:

$ mkdir outer
$ mkdir outer/inner
$ mkdir outer/sub
$ echo red >outer/red.txt
$ echo blue >outer/inner/blue.txt
$ echo green >outer/sub/green.txt
$ cd outer/inner/
$ hg init
$ hg add
adding blue.txt
$ hg commit -m "create inner"
$ cd ..
$ hg init
$ hg add
adding red.txt
adding sub/green.txt
$ hg commit -m "create outer"
$ hg status
A red.txt
A sub/green.txt
$ hg commit -m "create outer"

As you can see, when i add to the outer repository, it ignores the inner directory.

If you wanted to be extra sure, you could add the inner directory to your .hgignore.

Tom Anderson
No need not put anything in your `.hgignore` -- as you say, Mercurial will on purpose ignore nested repositories and this is exactly to allow people (such as the Mercurial developers themselves...) to version their home directories :-)
Martin Geisler
@Martin: that would explain it! I suggested using .hgignore more as some cheap anxiety therapy for the OP than anything.
Tom Anderson
Tom: hehe, I like the idea of curing anxiety with a doses of `.hgignore`! :)
Martin Geisler
A: 

There is a "subrepositories" feature that was added to Mercurial in version 1.3, and is supported in 1.5, which allows some hg commands to act on nested repositories recursively.

Araxia