tags:

views:

79

answers:

3

I commit some 3rd party tools that i decided not to use afterwards and removed them from hg again.

Thing that i dislike - they are still kept in history. Normally this is a good thing of course, but for this particular case - that's just a waste of space.

What are options to intentionally mess around with hg repository history and weed it out?

+3  A: 

If you don't mind having to switch to a new repository, your best bet would be to use the convert extension.

You can pass a filemap that excludes any files that you want to exclude and it will create a new repository for you, without any references to your files. Of course, this means having to clone a new working copy.

This means every working copy for the repository, so if there are a lot of working copies around, be prepared to do a lot of work.

Lennaert
Convert with a filemap is exactly the right answer, but I want to draw a big red box around "If you don't mind having to switch to a new repository". The contents of a changeset in mercurial (among other things) yield its hash and changing those contents change the hash. So if you edit history every clone you have will be invalidated and will also need to switch to the repo to be able to push/pull without doubling up everything. Lennaert understands this, but I wanted to make sure you do, because editing history isn't something to be done lightly -- it has to be done _everywhere_.
Ry4an
@Ry4an: Good point! Added a warning, thanks :)
Lennaert
http://board.koffer.ee/files/what_has_been_seen_cannot_be_unseen_695.jpg What has been seen, cannot be unseen... Anyway - thanks.
Arnis L.
+1  A: 

You might want to have a look to this guide on how to edit the Mercurial history.

Roberto Aloi
+1  A: 

Activate the mercurial queue extension and use "hg strip" to rewrite history. If you have any clone out there, push their changes and destroy them, do the "hg strip" and clone again.

If there are clones out there you can not control, all the bets are off. I would use the "convert" extension to rebuild the repository, do the "hg strip", and replace the old repository. Old clones will get an error when trying to push/pull, because the new repository has a different UUID, so the users will know they must destroy+clone again.

jcea