You are not logged in.

#1 2012-10-01 23:44:37

dammannj
Member
Registered: 2009-01-28
Posts: 44

Mercurial and subdirectories

Hi folks,

using mercurial, I found the following behaviour:

#mkdir -p test_parent/test_child
#cd test_parent
#hg init
#cd test_child
#hg init
#touch test
#hg st
 ? test
#cd ..
#hg st
*empty* 

In other words, mercurial does not detect changes made in subdirectories which are also repositories.

Is this a documented feature, or expected behaviour?

I find this very useful at times and would like to be sure before using it for any projects of mine.

Thanks and kind regards

Offline

#2 2012-10-01 23:54:32

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 18,577
Website

Re: Mercurial and subdirectories

man hg wrote:

init
      Initialize a new repository in the given directory. If the given directory does not exist, it will be created.

You are talking about two separate repositiories; that is the behaviour I would expect...


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

#3 2012-10-02 11:50:03

dammannj
Member
Registered: 2009-01-28
Posts: 44

Re: Mercurial and subdirectories

What I did not expect is that, even though the "parent" repository contains the "child", the "child" does not have to be ".hgignore"d...
Is anyone actually using this?

Offline

#4 2012-10-02 15:52:54

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 12,744

Re: Mercurial and subdirectories

<Soapbox>  You are exploring the unexpected behavior of a command while running as root? </soapbox>  tongue


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Like you, I have no idea what you are doing, but I am pretty sure it is wrong...Jasonwryan
----
How to Ask Questions the Smart Way

Online

#5 2012-10-02 17:28:59

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 18,577
Website

Re: Mercurial and subdirectories

dammannj wrote:

What I did not expect is that, even though the "parent"
repository contains the "child", the "child" does not have to be ".hgignore"d...
Is anyone actually using this?

I don't think that you should use the parent/child analogy, as it just confuses
the issue; while it may hold for the directory structure, once you have
initialized the new repository then—for all intents and purposes—they are
completely separate.

This comes in particularly handy when you 'hg qinit' inside an existing
repository…


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

#6 2012-10-02 18:14:34

dammannj
Member
Registered: 2009-01-28
Posts: 44

Re: Mercurial and subdirectories

@ewaller: just typed those commands from memory and put a # in front of them to distinguish commands from output. Did not think about # as root designator in PS1... wink

@jasonwryan
Here is the difference to hg qinit (or hg init --mq): this new repository "lives" inside the .hg directory, which is "ignored" by hg as it holds all revision information.

To rephrase my question: Is it expected that a repository in a subdirectory of a repository will be "ignored"? Or as you put it: Is it by design that they are - for all intents and purposes - separate repositories?
I ask as I don't remember comming across this info when reading the mercurial docs and tutorials.

Offline

#7 2012-10-02 18:54:03

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 18,577
Website

Re: Mercurial and subdirectories

dammannj wrote:

Is it expected that a repository in a subdirectory of a repository will be "ignored"? Or as you put it: Is it by design that they are - for all intents and purposes - separate repositories

It is a design feature: if you have initialized multiple repos in the same directory and they were not completely separated then you would quickly descend into a mire of recursion...


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

#8 2012-10-03 10:40:57

dammannj
Member
Registered: 2009-01-28
Posts: 44

Re: Mercurial and subdirectories

Exactly my thoughts! Just wondered whether this was made explicit anywhere.

As I understand it, when you are in some directory, and type 'hg <something>'; hg will loke at the parent directories till it finds a .hg directory which holds repo info.
In contrast to for example subversion, where each directory holds it's own part of the repo as far as I understood.

Now as I see it, tracking changes stops when a subdirectory is hit which contains a '.hg' directory.

I wonder why this is not mentioned somewhere? :S

Thanks for your answers and putting up with me being insistent wink

Offline

#9 2012-10-03 17:41:59

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 18,577
Website

Re: Mercurial and subdirectories

dammannj wrote:

I wonder why this is not mentioned somewhere? :S

Thanks for your answers and putting up with me being insistent wink


It may be in the Mercurial Guide...


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB