How to make local clone without pulling subrepos again?

倾然丶 夕夏残阳落幕 提交于 2019-12-12 08:54:16

问题


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).


回答1:


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.




回答2:


You can achieve this by cloning the subrepositories yourself. Supposing that foo has a single subrepo called bar:

$ cd ~/Development
$ hg clone -U /clones/foo
$ hg clone -U /clones/foo/bar foo/bar
$ hg update -R foo

The update does not need to access the internet since the subrepository exists and contains the necessary changeset for the update on the master.



来源:https://stackoverflow.com/questions/9427988/how-to-make-local-clone-without-pulling-subrepos-again

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!