1

I have a local repository, let's call it ONE. ONE is the actual program. It's an android program, in case it matters for some reason.

I have a remote repository, let's call it EXT. EXT is somewhat a library, used by ONE.

ONE has a complex directory structure, mandated by android. The main sources are in src/bla/bla/ONE. Since ONE uses EXT, to do it I had to create another directory next to that one, that is src/bla/bla/EXT.

I think would like to keep them separated in two repositories, but I need for them to actually be in this same directory structure to compile ONE.

At the moment I just created a symlink to do it, but I wonder if there is a better way of doing that, that uses some hg feature.

o0'.
  • 11,739
  • 19
  • 60
  • 87

3 Answers3

4

Subrepositories are great for this. Take a look at this related SO question: (how do I add a subrepo to an existing repo in mercurial.

Community
  • 1
  • 1
RyanWilcox
  • 13,890
  • 1
  • 36
  • 60
  • +1 for subrepos. Here's a [wiki manual](http://mercurial.selenic.com/wiki/subrepos) about hg subrepos. – Santa May 28 '10 at 19:58
1

I'm no expert on this, but I don't think sub-repositories work in this case.

You have 2 projects with the same deeply nested directory structure:

Project "ONE":

ONE
    /src
        /bla
            /bla
                /ONE

Project "EXT"

EXT
    /src
        /bla
            /bla
                /EXT

When you compile these projects you want the following structure:

Compile Project
    /src
        /bla
            /bla
                /ONE
                /EXT

Or something similar - essentially both source trees combined under a single "src".

Since you can't checkout part of a repository, wherever you create a sub-repository you'll get the full "EXT" directory. So, if you make a subrepo next to "ONE" you'll end up with:

Combined Project
    /src
        /bla
            /bla
                /ONE
                /src
                   /bla
                       /bla
                           /EXT

What you are after is a "Partial Clone", which doesn't exist yet.

https://www.mercurial-scm.org/wiki/PartialClone

I think OS links are the way to go.

Hope this helps.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Nick Pierpoint
  • 17,641
  • 9
  • 46
  • 74
  • Oh :( thanks. BTW it's even more complicated than that: ONE project also includes file upper in the tree. – o0'. Jun 01 '10 at 10:34
0

Use hg subrepos. For example:

$ git init ONE-proj
$ cd ONE-proj
$ mkdir -p src/bla/bla/ONE
$ ... # commit your initial project files for ONE
$ echo src/bla/bla/EXT = /path/to/hg/repository/EXT > .hgsub
$ hg add .hgsub
$ hg clone /path/to/hg/repository/EXT src/bla/bla/EXT
$ hg commit
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Santa
  • 11,381
  • 8
  • 51
  • 64
  • 1
    Does this work? Wouldn't you end up with "ONE" in src/bla/bla/ONE and "EXT" in src/bla/bla/ONE/src/bla/bla/EXT? – Nick Pierpoint Jun 01 '10 at 09:27
  • Those commands are executed under the repository's root directory, so everything is relative to that. – Santa Jun 01 '10 at 16:04