Mercurial development workflow

Giorgos Keramidas keramida at ceid.upatras.gr
Wed Aug 1 05:08:44 CDT 2007


On 2007-07-31 22:44, Martin Geisler <mgeisler at mgeisler.net> wrote:
> Thanks for the tip about the transplant extension, its good to know
> that there are ways to fix things if one commits on the wrong tree.
> 
> In general I must say that I have been pleasantly surprised by how one
> can undo some things with hg, it is very useful!

Indeed.  As long as the changes haven't been pushed out to another
repository, the flexibility of Mercurial in editing, tweaking, updating
and generally 'fixing' commits is astounding :-)

> I've already used the 'hg rollback' command a couple of times to
> correct typos in commit messages or to add files that I missed in the
> first commit (exactly the kind of situation described in Chapter 9 of
> the excellent book by Bryan O'Sullivan).

Another way to 'edit' local commits is to use the MQ extension.

You can 'import' the tip of a repository into a 'patch queue' with:

	% hg qinit -c
	% hg qimport -r tip -n demopatch

Then you should see a 'local patch' with:

	% hg qapplied -s

You can edit a few more files, use 'hg delete', 'hg rename' or make any
other local change, and then 'refresh' the patch with:

	% hg qrefresh --git

Finally, when the patch has reached a stable state, and you want to
convert it back to a 'real changeset', you can run:

	% hg qdelete -r tip

and voila: your old tip has been 'edited in place' :-)



More information about the Mercurial mailing list