开发者

How cut the mercurial repository from certain revision / push

开发者 https://www.devze.com 2023-01-17 15:46 出处:网络
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?开发者_J

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?开发者_JAVA技巧 In SVN there is dump command, which copies whole repository from one revision to another. There is some substitute in Mercurial or some other way?


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...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消