I've been trying to set up a project using bitbucket which has project dependencies hosted on github. Using the Hg-Git Mercurial plugin I am able to almost get there.
But when it comes time to push, things become troublesome.
The documentation for Mercurial subrepositories states:
2.4 Push
Mercurial will automatically attempt to first push all subrepos of the current repository when you push. This will ensure new changesets in subrepos are available when referenced by top-level repositories.
But this causes a big issue since I don't want to push all the subrepositories (why would I?) — I only have read access to them, so github won't allow it. Only the main repository needs to be pushed to the remote server, but I can't figure out how to do it. hg
wants to take control and push all subrepositories, regardless of whether or not there are changes. Is there some way to bypass this feature?
The only things which need to be pushed are .hgsub
and .hgsubstate
. Once they've been pushed via alternative routes (updating to a changeset where the subrepositories don't exist), it's possible to then update and pull the changes from the remote repositories, but if I were to push again whilst on a changeset with the subrepositories, the whole ordeal repeats itself.
This isn't possible due to Mercurial's method of pushing. This is a by design error.
The best solution is to update to a previous revision where the subrepositories don't exist, and then push. This will bypass Mercurial's restriction and upload the necessary .hgsub
and .hgsubstate
files. This is a little inconvenient, but is the best way I've found so far to get Mercurial and Git to work with each other.
Perhaps in the future Hg-Git will be updated to handle this use case automatically.