How to apply commit to local changes?

Martin Geisler mg at lazybytes.net
Wed Jan 20 05:19:14 CST 2010


Aleksa Todorovic <alexione at gmail.com> writes:

> Hi!
>
> I accidentely commited some changes I didn't want to (let's call it
> commit A). So, I updated to previous revision, and continued
> development. Now, I want to apply commit A to my local modifications
> so I can pick changes which I want to commit, and others which I want
> to discard. I can, certainly do this "by hand", or through patch, but
> does Mercurial supports this operation?

Use 'hg revert'. That command is used to change the *content* of files
to match a particular revision. By default 'hg revert foo.c' will revert
foo.c to how it looked in the working directory parent revision (see 'hg
parents').

But you can use 'hg update --rev X foo.c' to make foo.c look like it
does in revision X. You can then edit the file further and make a commit
like normal.

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.


More information about the Mercurial mailing list