views:

41

answers:

2

I have broken some code in my last 4-5 revisions / pushes to main repository. At now I want to completely delete this pushes and start HEAD of my repository from that point. How can I do that? In SVN there is dump command, which copies whole repository from one revision to another. There is some substitute in Mercurial or oher way?

+3  A: 

You can use the convert extension to do that.
Although, I don't really understand why people always want to hide/remove in their VCS history that they made a mistake. It's not that critical as long as you fix it in a newer revision...

gizmo
gizmo, I agree completely about deleting history being a bad idea.
Ry4an
+1  A: 

Quardas, "completely deleting" isn't part of mercurial's default vocabulary. It's a system built around immutable history. You can reverse something you regret, but you don't delete it. Think of a scientist in his/her lab writing with pen on numbered pages in a logbook -- ripping out a page is considered fraud. There's value in having your blind-allys and mistakes retained if only so you remember not to try that again.

Consider using hg backout which easily and automatically adds the inverse of a changeset thus undoing it completely, but preserving the record of both the changeset and the reversal of it.

If you really can't buy into that concept try looking into clone -r. It lets you clone your repository up to a certain point. For example:

hg clone -r -6 myrepo partial-myrepo
mv myrepo myrepo-with-stuff-I-regret
mv partial-myrepo myrepo

that will replace your repo with a new copy that omits the last five changesets.

Ther are plenty of other ways to do the same thing using tools that aren't part of mercurial's default toolset (extensions such as histedit, strip, mercurial queues, etc.) but you're best off not deleting history at all and doing it w/o extensions if you do.

Ry4an