Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a Git subrepository to Mercurial

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.

like image 323
summatix Avatar asked Oct 30 '10 08:10

summatix


2 Answers

For future reference, the development branch of mercurial (and thus the upcoming 1.8 release) now supports native git subrepos. This particular case is implemented very nicely and a push from the root repository will only tell the git subrepo to push if its remote repository is not known to have the current commit.

like image 69
homa_rano Avatar answered Oct 10 '22 17:10

homa_rano


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.

like image 45
summatix Avatar answered Oct 10 '22 17:10

summatix