0

I've set up a Mercurial repository that has a subversion subrepository. I've configured an .hgsub file so that Mercurial is aware of that repository. However, I was expecting that Mercurial could trigger an svn update automatically whenever I did a pull on the repository.

Is this possible with Mercurial subversion repositories? If not, what's the advantage of having the .hgsub file at all as opposed to placing that subdirectory in .hgignore?

Jon Adams
  • 24,464
  • 18
  • 82
  • 120
Rich
  • 12,068
  • 9
  • 62
  • 94

1 Answers1

3

Mercurial does not automatically pull/update subrepos. From hg help subrepos:

Subrepos do not 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.

Thus, updating subrepos is a manual process. Simply check out target subrepo at the desired revision, test in the top-level repo, then commit in the parent repository to record the new combination.

Placing the repo in .hgignore would not allow you to track which version of the subrepo is compatible/tested with each version of the parent.

In SVN terms, this is similar to create an svn:external link which is bound to a specific SVN revision.

Tim Henigan
  • 60,452
  • 11
  • 85
  • 78
  • The problem with this is that if a new user were to clone the hg repository, the initial pull would fail since there would be no svn repository as of yet to match up with the .hgsub file. Instead new users must first add the subrepository before they can add the main repository. Is there any clean way to handle this? – Rich Jul 28 '11 at 22:26
  • The only user that needs to manually clone the subrepo is the one who creates the subrepo link. Once `.hgsub` is pushed, the next user to clone or pull will automatically get the subrepo. When `clone` or `pull` encounter a changeset containing subrepos, it attempts to pull the specified subrepos and update them to the appropriate state. – Tim Henigan Jul 29 '11 at 01:26
  • Thanks for the clarification. When I tried this with TortoiseHG it failed and I didn't think to try on the command line. I suspect this is a bug with TortoiseHG. – Rich Jul 29 '11 at 18:13