Mercurial: how do I create a new repository containing a subrange of revisions from an existing repo?

Viewed 27

I have a repo with subrepos, with a long history. At some point the main subrepo became fully self-contained (doesn't depend on other sister subrepos).

I don't care anymore about the history of the whole thing before the main subrepo became self-contained. So I want to start a new repo that contains just what the subrepo has in it from that moment on. If possible, please describe in terms of TortoiseHg commands.

2 Answers

You probably want to make use of mercurial's convert extension. You can specify revisions to be converted, paths, branches and files to include or exclude in the newly-created repository.

hg convert from-path new-repo

Convert is a default extension which just needs activation.

You might be able to weed out any other changesets you don't need by using the hg strip command.

It will entirely remove changesets (and their ancestors) from a repository. Most likely you would want to make a fresh clone and then work on stripping it down.

One potential pitfall is that the final stripped repo would still have shared parentage with the original; therefore the potential exists for someone to accidentally pull down again changesets which were stripped.

The hg convert command (noted in another answer) does not have this downside.

Related