tags:

views:

39

answers:

1

How do I can shrink a mercurial repository, removing too old changesets?

+3  A: 

Fundamentally, you can't. Mercurial has a hard and fast rule that a changeset can only exist in a repository if every one of its ancestor changesets also exists in that repository.

You can, however, create a new repository whose changesets correspond to a subset of the later changesets in another repository. They won't, however be the same changesets because they'll have different hash nodeids, and any clones from the original repo won't work with the new one ("unrelated repositories").

You could try to create a new repo reflecting only some of newer changesets in another repo using a process like this:

hg -R /path/to/bigrepo export 10:tip > latestchanges.patch
hg init newsmallrepo
hg -R newsmallrepo import < latestchanges.patch

That would copy only the changesets numbered 10 and later into new changesets with different hashes in teh new repository. It also won't work terribly well with merges.

Ry4an