how to "revert" a repository to remove a changeset

234 views
Skip to first unread message

John Stean

unread,
Mar 3, 2011, 10:42:11 AM3/3/11
to merc...@selenic.com
Hello all,

I have achieved what I wanted, but not how I expected and wanted some clarification please?

A user accidentally pushed a changeset to the wrong repository, so hg heads gave me:

>hg heads
changeset: 3773:1ee773923f19
tag: tip
parent: 3772:66b897092b20
parent: 3747:bff60c7821dd
user: xyz
date: Thu Mar 03 11:20:04 2011 +0000
summary: Merge

changeset: 1776:09c4d831d7b0
branch: zfblend
parent: 1195:fd87fc4f5113
user: abc
date: Fri Apr 02 11:52:46 2010 +0100
summary: Closing branch, this is approach never worked

I wanted to get the tip back to 3747, so I tried :

>hg backout -m "remove unwanted merge changeset" tip
>abort: cannot backout change on a different branch

So this was wrong, so ok I update the repo instead:

> hg update -r3747
xxx files updated, 0 files merged, xxx files removed, 0 files unresolved

So when i ran hg heads, I expected to see 3747 as the tip, but I got the same as before:

>hg heads

changeset: 3773:1ee773923f19
tag: tip
parent: 3772:66b897092b20
parent: 3747:bff60c7821dd
user: xyz
date: Thu Mar 03 11:20:04 2011 +0000
summary: Merge

changeset: 1776:09c4d831d7b0
branch: zfblend
parent: 1195:fd87fc4f5113
user: abc
date: Fri Apr 02 11:52:46 2010 +0100
summary: Closing branch, this is approach never worked

So I need time to think so I'll just rollback and read up some more:

>hg rollback
rolling back last transaction
>hg heads

changeset: 3747:bff60c7821dd
tag: tip
user: def
date: Wed Mar 02 16:05:47 2011 +0000
summary: issue 3492

changeset: 1776:09c4d831d7b0
branch: zfblend
parent: 1195:fd87fc4f5113
user: abc
date: Fri Apr 02 11:52:46 2010 +0100
summary: Closing branch, this is approach never worked


The question is, what should I have done to get back to r 3747 , and how did I do it when the hg heads after the update -r3747 said the tip was 3772, and only after a rollback did it get to 3747, which was totally unexpected.

Hope my question makes sense?

thanks

_______________________________________________
Mercurial mailing list
Merc...@selenic.com
http://selenic.com/mailman/listinfo/mercurial

Matt Mackall

unread,
Mar 3, 2011, 11:25:41 AM3/3/11
to John Stean, merc...@selenic.com
On Thu, 2011-03-03 at 15:42 +0000, John Stean wrote:
> Hello all,
>
> I have achieved what I wanted, but not how I expected and wanted some clarification please?
>
> A user accidentally pushed a changeset to the wrong repository, so hg heads gave me:
>
> >hg heads
> changeset: 3773:1ee773923f19
> tag: tip
> parent: 3772:66b897092b20
> parent: 3747:bff60c7821dd
> user: xyz
> date: Thu Mar 03 11:20:04 2011 +0000
> summary: Merge
>
> changeset: 1776:09c4d831d7b0
> branch: zfblend
> parent: 1195:fd87fc4f5113
> user: abc
> date: Fri Apr 02 11:52:46 2010 +0100
> summary: Closing branch, this is approach never worked

You seem to be using a fairly old version of hg that shows closed heads
with the heads command.

> I wanted to get the tip back to 3747, so I tried :
>
> >hg backout -m "remove unwanted merge changeset" tip
> >abort: cannot backout change on a different branch

Backout doesn't "get the tip back to 3747", it will simply introduce a
new changeset that reverses the changes in 3773.

> So this was wrong, so ok I update the repo instead:
>
> > hg update -r3747
> xxx files updated, 0 files merged, xxx files removed, 0 files unresolved
>
> So when i ran hg heads, I expected to see 3747 as the tip, but I got the same as before:

"Tip" is simply the highest numbered revision in your history. It has
nothing to do with the contents of your working directory.

"Update" simply changes the contents of your working directory. It has
no effect on the contents of your history.

If you're using named branches, you should probably forget that you ever
heard of tip.


--
Mathematics is the supreme nostalgia of our time.

Michael Jay Lippert

unread,
Mar 9, 2011, 9:35:17 AM3/9/11
to John Stean, merc...@selenic.com
If you want to remove a changeset as though it never existed, you could enable the mq extension and use the strip command.

Mike

Kevin Bullock

unread,
Mar 9, 2011, 10:43:00 AM3/9/11
to Michael Jay Lippert, John Stean, merc...@selenic.com
On Mar 9, 2011, at 8:35 AM, Michael Jay Lippert wrote:

If you want to remove a changeset as though it never existed, you could enable the mq extension and use the strip command.

...but don't without reading <http://mercurial.selenic.com/wiki/EditingHistory>!

pacem in terris / mir / shanti / salaam / heiwa
Kevin R. Bullock

Reply all
Reply to author
Forward
0 new messages