I am using subrepositories to share code between multiple projects. I keep the "master" version of these shared repositories in a central location. That way I can easily push changes I made to them in one project and pull them in another. That works, but ideally I want to just push the project repository and all subrepositories should be pushed to their origin. But Mercurial always pushes all subrepositories into the origin of the main repository.
This is my setup:
Project1 (default path = Project-Central-Location/Project1)
- lib-A (default path = Library-Central-Location/lib-A)
- lib-B (default path = Library-Central-Location/lib-B)
Project2 (default path = Project-Central-Location/Project2)
- lib-A (default path = Library-Central-Location/lib-A)
Library-Central-Location
- lib-A <= push of Project1 should push lib-A to this location
- lib-B
Project-Central-Location
- Project1
- lib-A <= push of Project1 pushes lib-A to this location instead
- lib-B
- Project 2
- lib-A
I ended up using hooks. First, the libraries inside the projects in the central location need to point to the corresponding central library repository:
Then you need to add this to their
.hg/hgrc
files:That way I will trigger a push to the central libraries anytime I push the projects.