views:

84

answers:

1

We have several shared libraries that exist as subrepos in a parent repo. If a person clones the parent repo, it looks something like:

/ParentRepo
---- .hg
---- .hgsub
---- .hgsubstate
---- SharedSub1
---- SharedSub2
---- SharedSub3
---- SharedSub4
---- ParentRepo.sln

.hgsub looks like this:

SharedSub1 = http://ourfogbugz.us.com/..../SharedSub1
SharedSub2 = http://ourfogbugz.us.com/..../SharedSub2
SharedSub3 = http://ourfogbugz.us.com/..../SharedSub3
SharedSub4 = http://ourfogbugz.us.com/..../SharedSub4

Each subrepo's hgrc looks something like this:

default = http://ourfogbugz.us.com/..../SharedSub1

Pretty standard stuff.

But!

How, using this setup, does a co-worker pull from another without using a central server as the intermediary? So co-worker A does 'hg serve', and B does 'hg pull http://coworkerA.us.com:8000'... but this will fail, as the hgsub file is still pointing at the central server, and thus B will only get changes from the central server, and not get any changes from A's subrepos that do not exist on the central server.

This is further complicated if the central server is down or unreachable. There is no way for people to pull from each other directly using subrepos!

How is pulling between co-workers done using subrepos? Editing the hgrc and hgsub files is out of the question, because you'd have to do it for each subrepo (we have around 20), and once for each co-worker!

I have also posted this question on the Kiln StackExchange to hit a broader audience: http://kiln.stackexchange.com/questions/1780/pulling-from-a-co-worker-when-using-subrepositories

+2  A: 

You can (and generally should) use relative paths in your .hgsub entires. If those lines were:

SharedSub1 = ../SharedSub1
SharedSub2 = ../SharedSub2
SharedSub3 = ../SharedSub3
SharedSub4 = ../SharedSub4

then you could clone from central, from a friend, or a local clone on your own.

Ry4an
So the .hgsub file, on the central server, would have relative paths? When you clone that to local, does it mean you would need separate copies of all the subrepos one directory up as well?
Andrew
You'd need one copy of each, yes, but multiple clones of the top level project could point to the same ../SharedSub1 local clone -- their working dirs aren't used and the revision-to-use is stored in the local clone of the parent repo's .hgsubstate so they won't run into one another.
Ry4an
But you would still have to manually clone all the SharedSub(s), right? Granted, this is a one time operation, but it's a big impediment. Also, have you gotten relative subrepos to work properly with "hg serve"?
Andrew