views:

88

answers:

3

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.

A: 

If you have no outgoing changesets in the subrepository, the 'push' should actually do nothing other than retrieve the latest changeset list from the remote repository. Therefore, the actual 'push' part of the push won't happen. I've successfully used read-only BitBucket repositories as submodules.

Michael E
Yes it should, which is exactly what it does — however the push does actually happen, it's just that if there are no changes then nothing will be uploaded. Github forces you to authenticate yourself before checking to see if there are any changes. So for this to work, the push needs to be ignored completely.
summatix
A: 

I think you should use multiple repositories; DVCS works better like that.

For example, make one repository that contains the dependencies from github. You only pull in that repo to get the changes, you never push. Then you have another repository for your project, for development. Here you are free to do whatever you want. And then you link to your own hg repo for the dependencies.

That's if I correctly understood your problem and what you're trying to do :)

anothem
Sorry, I don't understand. My problem is that I need Mercurial and Git to play nicely with eachother — which they do. But hg's so-called feature just makes things a little troublesome.
summatix
It is not a "so-called feature", it's an essential step in working with hg. Push/pull synchronizes your local repository with the remote one. What I am suggesting is that you might need a different repository configuration for what you are trying to do; it's common when using git/mercurial to have multiple repositories for your project. Pushing in your mercurial repo shouldn't affect the stuff you are trying to get from github and of course you shouldn't be pushing into the github repo.
anothem
We are clearly on different playing fields here
summatix
A: 

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.

summatix