Here are the steps I've taken to build the repo and subrepos.
Everything is hosted on Bitbucket.
- Per best practices, created a skeleton repo to hold all of the subrepos. Cloned to my machine.
- Cloned primary project as subrepo1 (within the mainrepo directory structure).
- Added primary project to mainrepo as a subrepo1.
- Committal of mainrepo works as expected.
- Pushed successfully mainrepo and subrepo1 to Bitbucket.
- Proceeded to clone another subrepo2 to mainrepo directory.
- Added subrepo2 to mainrepo as subrepo2
- Committal of mainrepo works as expected.
- Push of mainrepo results in "Repository is unrrelated" error after is "searching for changes" Error occurs only on the newly added subrepo2.
Here is directory structure: mainrepo --subrepo1 (main project) --subrepo2 (class library)
I've spent countless hours trying to get this working and I must be missing something obvious.
What is causing this error and what am I missing? I need to be able to add additional subrepos as the project grows.
The steps that I took to make my example are as follows:
MainRepo
on BitBucketSubRepo
on BitBucketMainRepo
SubRepo
as a sub-directory ofMainRepo
.hgsub
file with the contentsSubRepo = ../SubRepo
.hgsub
file toMainRepo
, commit and pushSubRepo2
on BitBucketSubRepo2
as a sub-directory ofMainRepo
.hgsub
and addSubRepo2 = ../SubRepo2
MainRepo
againFrom then on, I could edit either of the two sub-repositories and see that they had changed when looking at
MainRepo
in the workbench. I could then commit the changes to the sub-repositories, commit the sub-repository states inMainRepo
and push all three repositories with a single push fromMainRepo
The way that you said that it was set up by TortoiseHg in your other question (
subrepo = subrepo
) won't work with BitBucket because of how their structure is. I think that you can only have repositories at the top level like this:whereas having the line
subrepo = subrepo
is trying to set up a structure like this:When you push this it looks like it is trying to push
SubRepo
intoMainRepo
which would explain the unrelated repository error message that you are getting.The
.hgsub
syntax is such that the left of the equals defines the folder in the working copy where the repository will be and the right of the equals defines where to get it from. When the right of the equals is a relative path, it defines where the sub-repository is on the central server relative to the main repository. So in the example above, you go up one folder tobitbucket.org/SteveKaye
and theSubRepo
is contained in that folder.The documentation says:
This looks relevant to your situation when using BitBucket and I'd expect that your clones can't be cloned as it says in the last sentence.