Precision on "sub-repository"
Thomas Arendsen Hein
thomas at intevation.de
Fri Jul 7 16:36:13 UTC 2006
* Mathieu Clabaut <mathieu.clabaut at gmail.com> [20060707 15:18]:
> In two words : What are the links between a repository and its
> potential subrepository
They are not linked, but they ignore each other, i.e. the outside
repository doesn't touch the inside one.
> (I see two case : a subrepository created by "hg init"
Yes, that's what I talk about.
> and another one created by "hg pull unrelated_project"
This is no subrepository, just a branch that can be merged or not.
Unrelated repositories pulled in are in fact not completely
unrelated, since all repositories have the same first changeset:
-1:0000000000000000000000000000000000000000
> Is the subrepository controlled by the repository ? If not what
> happens if I do an "hg add subrepository; hg commit" (I tried and it
> works ok, but It seems that it gives 2 unrelated history.. which may
> be the intent)..
This is dangerous, don't try this at home. Repositories ignore each
other, but as with .hgignore this ignorance can be overridden with
an explicit 'hg add'.
> How are the history of the two related ?
No.
> In other words, If I have an existing project "foo", and I want to
> include it in a larger project "bar" in the directory dir/foo, should
> I do in "bar" :
> hg pull foo_url
> hg update
> hg move bar dir/foo
> hg commit ?
This is possible, though there might be files with the same name.
You can circumvent this with an intermediate repository where you
move the files:
hg clone foo_url
cd foo_url
mkdir sub
hg mv this that something sub
hg ci -m 'moved everything to sub'
cd ../yourproject
hg pull --force ../foo_url
hg merge
hg commit -m 'merged in foo_url under sub'
Now you have _one_ repository, not two.
If you want to have a subrepository, you just do:
hg clone foo_url sub
Now you still have to commit/pull/push/in/out/everything them
separately.
> All this question are also loosely related to my previous question :
> Is it possible (or imaginable) to do a partial clone ?
I can imagine something similar to history punching:
http://www.selenic.com/mercurial/wiki/index.cgi/TrimmingHistory
(ignore the reference to "PartialClone" there, this is just
PartialCheckout)
Instead of throwing away old content you could also throw away all
filerev contents you don't want.
So yes, it is possible.
Thomas
--
Email: thomas at intevation.de
http://intevation.de/~thomas/
More information about the Mercurial
mailing list