tags:

views:

99

answers:

2

Is there a way to clone a repo that comes with subrepos, but without having Mercurial pull all the subrepos?

It appears that while hg clone -U can be used to obtain an empty clone of a repo, there's nothing that would convince hg update to avoid starting off by pulling all of the subrepos.

I should point out that it is crucial to retain the ability to easily sync to the head revision after creating such a clone.

+1  A: 

If you have a subrepo, a working directory must include some version of that subrepo. That version may be a fixed older revision if specified, or the tip if not.

You cannot update your repo without getting the subrepos; if you had a complete working dir without them, you shouldn't be using subrepos - use truly external repos instead.

If your subrepos are pegged against a certain remote version, then updates after the first will not trigger a subrepo update - they're already up-to-date. But for the initial creation of the working directory, you will have to do a remote pull.

You can trick Mercurial by munging the hgsubstate file. But really, your model and the conceptual model differ, so you're probably not a good match for subrepos if this is a concern.

edit: If you find yourself cloning and then updating to the tip many times, try using local branches or mq instead. That way you only have to do the initial clone once.

Borealid
They seem a good match most of the time. It's just that the subrepos are large, and the best way to diff against the official "server" that I found is to keep a clean local checkout. The subrepos add a ton of overhead to this approach.
romkyns
@romkyns: if you're just looking to keep track of what you've changed, use `hg out` (or `hg diff` for uncommitted changes). Or you could just create the "clean" clone once, and use `hg pull -u` on it occasionally to keep it up to date...
Borealid
Thanks, I guess I'll just have to tolerate a bunch of extra copies of these huge subrepos. I find `hg diff` suboptimal for reviewing code and use external GUI-based diff instead.
romkyns
romkyns: `hg diff` will use your external diff viewer if you set it up right. Also, do take a look at `hg mq`. Really. Quilt is a nice program.
Borealid
+1  A: 

Found a hacky way. It still requires all subrepos to be checked out once, but afterwards they can be deleted.

  1. Clone the whole lot, including subrepos. No way around this.
  2. Delete subrepos
  3. hg remove .hgsub

I tried to convince Mercurial to hg remove .hgsub before the subrepos are cloned, but the best I got is not removing .hgsub: file is untracked.

romkyns