Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove certain changesets from a specific Mercurial clone?

Tags:

mercurial

I have a clone of a central repo at rev 2048. I want to remove the last 10 changesets on my local repo as if I was back in time two weeks ago. I suppose I could delete my local repo and do "hg clone -rev 2038" but that would be long (cloning the repo takes several minutes). Is there a way to just "unpull" some changesets?

Notes:

  • I'm not trying to backout the changesets. I'll eventually pull those changesets again from the central repo.
  • I'm not trying to update the working directory to an earlier version; I really want to affect the repository.
  • I don't have any outgoing changesets or pending modifications in my current repo and working directory.
like image 264
Sylvain Avatar asked Dec 23 '10 16:12

Sylvain


People also ask

How do I clone a Mercurial repository?

Clone a remote Mercurial repositoryFrom the main menu, select Hg | Get from Version Control. The Get from Version Control dialog opens. In the dialog that opens, select Mercurial from the Version control list and specify the URL of the remote repository you want to clone. Click Clone.

How do I cancel my Mercurial repository?

Jonathan: Removing it is quite proper. We try to keep simple things simple in Mercurial: hg init creates . hg for you, and rm -r . hg will undo that.


1 Answers

Use the strip command:

hg strip -r 2039 

This command is provided by the StripExtension. It is distributed as part of Mercurial 2.8 and later, but you do need to enable it first by adding the following lines to your .hgrc or Mercurial.ini:

[extensions] strip = 

Before Mercurial 2.8, it was part of the MqExtension.

To prevent you from accidentally destroying history, the command will generate a backup bundle in .hg/strip-backup/ which you can hg unbundle again if desired.

like image 179
Wim Coenen Avatar answered Oct 03 '22 12:10

Wim Coenen