How to get rid of older mercurial heads?

为君一笑 提交于 2019-12-12 07:30:29

问题


Hi I hope you can from my i/o tell how to proceed to merge everything to the latest update without losing my changes:

$ hg merge
avbryter: grenen 'default' har 4 huvuden - sammanfoga med en specifik rev
(kör 'hg heads .' för att se huvuden)
ubuntu@ubuntu:/media/Lexar/montao$ hg heads
ändring:     192:e571b17295e9
märke:       tip
förälder:    175:f50d4c4461e5
användare:   tekniklas
datum:       Sat Jan 08 04:45:07 2011 +0000
kortfattat:  twitter support added

ändring:     191:9e419ce3e7e1
användare:   tekniklas
datum:       Wed Mar 09 12:56:27 2011 +0000
kortfattat:  adsense maps

ändring:     159:f8d974793b12
förälder:    157:ef1d955b9236
användare:   tekniklas
datum:       Sat Dec 18 17:05:45 2010 +0000
kortfattat:  remove

ändring:     89:008a2ac46b4f
användare:   tekniklas
datum:       Sun Aug 01 07:10:40 2010 +0000
kortfattat:  classifiedsmarket/market/market_ad_preview.html

ubuntu@ubuntu:/media/Lexar/montao$ 

The latest version is good and I want to "lose" the older heads.

UPDATE. After proceeding with the tip this is the latest output from hg heads:

    $ LC_ALL=C hg heads
changeset:   195:fa7d0ec3760d
tag:         tip
user:        tekniklas
date:        Fri Mar 11 06:04:17 2011 +0000
summary:     searchbox

changeset:   192:e571b17295e9
parent:      175:f50d4c4461e5
user:        tekniklas
date:        Sat Jan 08 04:45:07 2011 +0000
summary:     twitter support added

changeset:   159:f8d974793b12
parent:      157:ef1d955b9236
user:        tekniklas
date:        Sat Dec 18 17:05:45 2010 +0000
summary:     remove

changeset:   89:008a2ac46b4f
user:        tekniklas
date:        Sun Aug 01 07:10:40 2010 +0000
summary:     classifiedsmarket/market/market_ad_preview.html

EDIT, current issue status is:

$ LC_ALL=C hg heads
changeset:   195:fa7d0ec3760d
tag:         tip
user:        tekniklas
date:        Fri Mar 11 06:04:17 2011 +0000
summary:     searchbox

changeset:   192:e571b17295e9
parent:      175:f50d4c4461e5
user:        tekniklas
date:        Sat Jan 08 04:45:07 2011 +0000
summary:     twitter support added

changeset:   159:f8d974793b12
parent:      157:ef1d955b9236
user:        tekniklas
date:        Sat Dec 18 17:05:45 2010 +0000
summary:     remove

changeset:   89:008a2ac46b4f
user:        tekniklas
date:        Sun Aug 01 07:10:40 2010 +0000
summary:     classifiedsmarket/market/market_ad_preview.html

ubuntu@ubuntu:/media/Lexar/montao$ LC_ALL=C hg --config ui.merge=internal:local merge 195
abort: merging with a working directory ancestor has no effect

回答1:


Mercurial is about building a permanent history of your work, so none of its normal usage modes include "getting rid" of old heads.

The most Mercurial-like way to do this is to merge that head in selecting nothing from it.

hg update tip
hg --config ui.merge=internal:local merge 191 # keep my files

Found here.
That will eliminate that head, selecting nothing from it.

Other options that actually remove it from history include just doing:

hg clone -r tip myrepo mynewrepo

Which gets you a new clone that has only your newest head and its ancestors (not its sibling heads) which you can replace your old repo with if you like the result.

That's generally inferior if you buy into the keep-everything-forever model (I do) and doesn't work at all if other people already have clones fo your repo.




回答2:


Nowadays you can close your branches (anonymous or not) with:

hg commit --close-branch -m "Closing branch."

You need to be in the branch you want to close before doing it.

I think that closing branches is better than merging it discarding changes because have a better meaning. When closing you said "This changes aren't useful any more", when merging you said "I like the changes but they are already included manually" (but maybe is what you wanted).

You can see this related question Mercurial: beheading a head or this one if you don't want/can't update Can you close a Mercurial branch without updating to it first?.




回答3:


You can close your old branches. See article from official wiki.




回答4:


Try to merge with lastest remote head and then push your commit

hg merge
hg commit -m 'merge'
hg push


来源:https://stackoverflow.com/questions/5249535/how-to-get-rid-of-older-mercurial-heads

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!