Wednesday 21 November 2012

Dangerous history editing with Mercurial

...let's be revisionist for once

I decided to stop worrying and love the bomb, it was time to edit the immutable repository history of Mercurial! Thanks to the power of hg I almost lost every changeset I was working on but in the end I succeeded in modifying a few past changesets.

I spent some time between documentation and tutorials so I'll sum up the most important commands with a brief description.

You start off by populating your queue with a few revisions with
hg qimport -r revision_start:revision_end
this will generate one .diff file in .hg/patches for each revision between revision_start and revision_end. Afterwards you remove every (with -a in the example) patch from your local repo, so that only the ones in .hg/patches exist. You do so with
hg qpop -a
and then you can edit whatever revision simply by modifying the equivalent rev.diff file. You can merge, delete and add changesets withqdelete qnew qfold
When you are done with modifications you just have to re-apply your revised patches with  
hg qpush -a
and complete the editing with
hg qfinish -a
Not bad.

No comments:

Post a Comment



All the projects here are under a Creative Commons 3.0 licence! You can use and distribute them as you like (just quote the author so he knows his work is not useless)!

If you wish to get in touch with me write at projectsymphony@gmail.com