I am curious if this is possible with Mercurial. I'd like to have a subrepos in a project that are always fixed to the manually specified changeset, or better yet - tag.
Basically what I am trying to achieve is to have a core system in the main repo and then all the modules and components in subrepos, but I don't want those subrepos to point to tip, only to the major releases of those components/modules(hence tags).
When you create (or update) a subrepository, Mercurial takes a snapshot of the subrepo’s state and stores it in the parent repository’s .hgsubstate file. This means that multiple projects can point to a single shared subrepository, yet each one can independently decide which revision of the shared repository to rely on.
hg commit and hg update go recursively through the subrepositories. If there is no change in a subrepository during a command, then there will of course not be committed to that subrepository. Other commands that can work on subrepositories need a --subrepos option to recurse through the subrepositories.
Therefore the repository is first updated and then the subrepositories are updated according to the updated version of the .hgsubstate file. This might also involve pulling from the subrepository path, if the revision in the .hgsubstate file has not yet been pulled. hg commit and hg update go recursively through the subrepositories.
From this dialog you can click the ‘Commit’ button next to the submodule and commit those changes with a message of your choosing, separate to the parent repo commit message. In Git, the ‘Skip’ button at the bottom is enabled so you can just leave the changes uncommitted if you like, but Mercurial doesn’t allow this.
Subrepositories work exactly like you want.
Mercurial never automatically update the subrepo to the tip. It always stays at the changeset you choose. From the documentation:
Subrepos don't automatically track the latest changeset of their sources. Instead, they are updated to the changeset that corresponds with the changeset checked out in the top-level changeset. This is so developers always get a consistent set of compatible code and libraries when they update.
To achieve what you want, you can follow the following steps:
echo subrepo = https://example.com/subrepo/repo/path > .hgsub
hg add .hgsub
hg clone https://example.com/subrepo/repo/path subrepo
hg -R subrepo update mytag
hg commit
This will create a subrepo directory with the content of the specified repository which will stay on the mytag
tag as long as you don't update manually to something else!
Everyone who clones your repository will have the subrepo on the same changeset as you (ie mytag
).
FYI, the changeset to which a subrepo is updated is stored in the .hgsubstate
file at the root of the main repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With