Pushing mercurial repo without pushing subrepos
Asked Answered
D

1

12

I'm using Mercurial 1.6. I have a repo with a few subrepos (11). I would like to push the parent repo to the default remote repo without pushing the child repos. Reasons for wanting to do this include:

  • I'm using SSH repos, and it takes a long time to establish a connection and push nothing to each of the subrepos.
  • I have commits in subrepos I don't want propagated to the remote repos (yet).
  • Subrepos have named branches that should not be propagated to the repote repos (and there's apparently no way to pass branch names to the push operation of the subrepos).

However, I've been unable to find a way to accomplish this. I tried deleting the content of .hgsub and .hgsubstate (without committing), but still mercurial insists on pushing the subrepos.

How can I push the changes from the local repo to the remote repo and ignore the subrepos temporarily?

Dionnedionysia answered 9/7, 2010 at 13:7 Comment(0)
E
4

I think you'll need to make local clones of the subrepos.

The problem with pushing the main repo without pushing the subrepos is that the contents of the subrepos are not part of the main repo - only their states are. The contents are referenced from the original location specified in .hgsub. So your main repo's .hgsubstate says "subrepo A is at revision abcd1234", but abcd1234 is a change you made that you don't want to push... and now what would happen if you cloned the main repo? It'd try to clone the subrepo from its original location and update it to abcd1234, but that revision doesn't exist in the original location, so the clone would fail.

Instead, you can make local clones of each external repository and reference those as the external locations of the subrepos. Then when you push the main repo, the subrepo changes will only propagate to your local clones. When you're ready to share those changes, just go over to the local clones and push from there, and you'll be able to pass branch names and so on.

Elephantine answered 21/12, 2010 at 18:54 Comment(3)
That makes sense, and it makes me think that we're not using subrepos the way they're intended to be used. We're mainly using them to easily check out a collection of repos... and our .hgsubstate always refers to NULL revisions of the subrepos. It seems that the hgforest extension (now deprecated) was better for our purposes than subrepos.Dionnedionysia
This makes sense, but Mercurial seems to be over-zealous. It will try to push abcd1234 even when that revision (nor any of its descendants) are called out in .hgsubstate. Even hg out --S -r . (the -S is for 'recurse into subrepos') doesn't list the subrepo changes.Mopey
Can we tell it to not push if phase of all change-sets are public, as this suggests (so long as we do not manually set phase to public) that it has already been pushed.Livable

© 2022 - 2024 — McMap. All rights reserved.