Friday, February 15, 2013

Sub repositories and Mercurial

So today I had finished up my game ready for release (Theseus and the Minotaur). Which can be found here.
One of the things I came across is how do I have sub repositories for both git and mercurial under mercurial?
I had a lot of trouble with it so here is what I've learnt.


First off you need anything e.g. build files or what ever specific to your project fork the sub repositories.
Then you can commit them freely to there.

Second under your root directory of the project create a file called .hgsub
For example:

  • root
    • .hgsub
    • project_dir
    • sub_project
.hgsub will contain e.g.
sub_project = https://user@url/repo
Where sub_project is the directory the repo is under and https://user@url/repo is the repository location.
Now repositories don't have to be remote.
They can also be local. So you can use a relative or absolute address of where the repo is located on your computer.

To support git the url is prefixed with [git] e.g. the url will be
[git]git@url:user/repo.git

With mercurial sub projects a file called .hgsubstate is created for you.
Do not modify it.
If you want to change the remote version of the sub repositories use the command within the sub project directory.
hg pull
hg up
This will get all changes then configure it to be the latest.
Afterwards in the parent directory (where .hgsub lives) commit the changes.

I hope this helps explains this a bit!

No comments:

Post a Comment