Question

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).

Was it helpful?

Solution

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:

  1. echo subrepo = https://example.com/subrepo/repo/path > .hgsub
  2. hg add .hgsub
  3. hg clone https://example.com/subrepo/repo/path subrepo
  4. hg -R subrepo update mytag
  5. 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top