Undoing a commit in my personal repository

Dave Brosius dbrosius at mebigfatguy.com
Thu Apr 22 14:27:43 CDT 2010


Similar to this line of questions, i don't understand why rollback is only
one level. why can't I rollback all the way to an empty repo if i like?
what is special about the tip that can rollback, but not others?

Yes, sure i can clone the repo at a revision... but just asking..

dave



----- Original Message -----
From: "Greg Ward" <greg-hg at gerg.ca>
Sent: Thu, April 22, 2010 15:10
Subject:Re: Undoing a commit in my personal repository


On Thu, Apr 22, 2010 at 11:13 AM, Aardwolf <toiletpot at gmail.com> wrote:
>
> Suppose I have this situation:
>
> *) I did a commit in my repository
> *) I did pull and update
> *) There are also still a few uncommitted files in my working directory
>
> Now I want the following:
>
> *) Still have the uncommitted files in my working directory
> *) Also undo the commit in my repository: have those changes also be moved
> back again to my working directory and the commit be undone

Should be doable.

> hg rollback doesn't work, that seems to roll back the pull instead of the
> commit, and can't be done twice in a row.

Correct.  The help says as much.

> I've read somewhere that there exist things to change history. Changing
> history in my personal repository shouldn't affect anyone.

Also correct.

Here's what I would do.

1) *make a backup* of the entire repo + working directory -- I might
have the wrong procedure or you might make a mistake
2) enable the "mq" extension (this is where the "strip" command comes from)
3) hg help strip to understand what we're going to do in a moment
4) hg update REV where REV is the changeset you want to undo
5) save your uncommitted changes, just in case: hg diff > patch2
6) save the committed change that we're about to destroy: hg diff -c
REV > patch1
7) destroy history: hg strip REV
8) apply the destroyed change: hg patch --no-commit --force patch1

(The changes in patch2 should still be in your working dir.)  (Step 8
is equivalent to "patch -p1 < patch1", but should work on Windows as
well as Unix.)

Completely untested.  YMMV.

Greg
_______________________________________________
Mercurial mailing list
Mercurial at selenic.com
http://selenic.com/mailman/listinfo/mercurial



----- End of original message -----



More information about the Mercurial mailing list