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.