开发者

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, eve开发者_如何学运维n though the files I need are right there.

This is a problem, right?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜