Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make local clone without pulling subrepos again?

I often work with Mercurial by keeping a local store of my upstream clones, and then just cloning again locally for my actual working environment:

$ cd /clones
$ hg clone ssh://external-repo.example.com/some/repo/path/foo
$ cd ~/Development
$ hg clone /clones/foo

This is particularly useful for me because I often want to make new clones on airplanes, etc., where I have no internet access. However, this doesn't work when the original clone contains subrepos - the presence of the .hgsubstate file means that hg will always go out to the internet instead of grabbing the local cloned revision (even if they are the same). Is there any way to make a local clone copy the files without going out to the internet?

This question has an answer which would probably work, but seems very unfortunate for long-term management (deleting the .hgsubstate file in the clone in /clones/, and then making local clones from that).

like image 553
Nick Bastin Avatar asked Feb 24 '12 09:02

Nick Bastin


1 Answers

You can use a "trivial" subrepository path in your .hgsub file like this:

foo = foo
bar = bar

This is the recommended setup. The advantage of setup a layout is that a clone has the same structure as the repository you clone from. You can thus clone your clones when on a plane.

Alternatively, you can use the [subpaths] setting to re-map the URLs to local paths. This lets you add

[subpaths]
http://server/(.*) = /clones/libs/\1

to your ~/.hgrc file and then you'll see that paths are remapped to /clones/libs when you clone.

like image 79
Martin Geisler Avatar answered Sep 23 '22 18:09

Martin Geisler