Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of older mercurial heads?

Tags:

mercurial

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
like image 912
Niklas Rosencrantz Avatar asked Mar 09 '11 17:03

Niklas Rosencrantz


3 Answers

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.

like image 171
Ry4an Brase Avatar answered Sep 23 '22 17:09

Ry4an Brase


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

like image 36
PhoneixS Avatar answered Sep 21 '22 17:09

PhoneixS


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

like image 38
shellholic Avatar answered Sep 21 '22 17:09

shellholic