Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial workflow with subrepositories and offline clones?

I'm offline a lot.

So normally, I use one local clone as a "hub" for features, bugs, etc.

hg clone local-hub bug-123

Works offline. Cool.

Can I use a similar workflow if that project contains remote subrepositories?

Because, if .hgsub says

sub/shared = http://server/hg/shared

hg clone says

abort: error: getaddrinfo failed

Note that once the clone is created (while connected), push and pull will use the path in the subrepo's hgrc (instead of the location in .hgsub). So I can point this to a local clone and everything is cool.

But clone looks at .hgsub (as it's supposed to). So if the "blessed" subrepo is on a server, I can't create new clones offline, even though the files I need are right there.

This is a problem, right?

like image 596
harpo Avatar asked Feb 24 '23 22:02

harpo


2 Answers

Ideally whomever set up the project uses relative URLs in their .hgsub file like this:

sub/shared = ../shared

and then, of course, actually makes shared a sibling of the main repo. Then as long as you have cloned down the main repo and the subs (as siblings) then everything will work out.

If they've used absolute URLs in their .hgsub file you can work around it using the subpaths section in your .hgrc like this:

[subpaths]
http://server/hg/shared = ../shared

which provides a translation layer in your client.

like image 51
Ry4an Brase Avatar answered Mar 03 '23 02:03

Ry4an Brase


The canonical way to use subrepositories is to have X = X paths in the .hgsub file:

sub/shared = sub/shared

That way a clone will structurally look just like the original -- and so you can use the clone to make further (local!) clones.

However, this is not always possible, for example, Bitbucket wont let you create the nested repositories on their server. In that case, the ../X style paths in the .hgsub file is better, and you can use the subpaths configuration section to translate these paths into paths you can use locally.

like image 27
Martin Geisler Avatar answered Mar 03 '23 03:03

Martin Geisler