Niklas Rosencrantz
Niklas Rosencrantz

Reputation: 26671

Mercurial questions how to handle different heads

My repository can't merge, can't pull and can't do update just because it can't simply close unwanted heads that were mistakes. It seems I've got changes in hg that complicates merging. I expect the changes (heads) to be rather irrelevant and I want to enable just one head and just one branch.

$ hg merge
branch 'default' has 4 heads    
$ hg merge -r e571b17295e9
outstanding uncommitted changes (use 'hg status' to list changes)
$ hg commit -m ''
nothing changed

Did I forget hg push or hg pull somewhere? If nothing changed, why does it say outstanding uncommitted changes? This is my latest output from hg head. How do I find out more about what these changes were? Why is it nearly impossible to do something as simple as getting rid of one of the heads? I'm not curious how hg defines a changeset, a revision, a head, a branch etc, I just want the simple actions to be simple.

$ hg head
ändring:     233:88de4be7943c
märke:       tip
användare:   niklasro
datum:       Mon Sep 05 18:30:37 2011 +0000
kortfattat:  addremove

ändring:     176:e571b17295e9
användare:   tekniklas
datum:       Sat Jan 08 04:45:07 2011 +0000
kortfattat:  twitter support added

ä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

I don't fully understand how to use mercurial and I want more control e.g. see what happened these dates when there were several so-called heads. I'm mostly the sole developer on this repository but want ability to update it from many locations. I asked before about these changes and I can't seem to figure out how to do a hg pull to sync from repository to local. I can do a hg clone and add changes but the listed changes above means that I forgot to sync something and I want to make it easier to

abort: unsynced remote changes?

How to see a mercurial difference

How to get rid of older mercurial heads?

Now hg diff, hg status and hg incoming don't display any changes and I've managed to clean the repository (which is on googlecode.com) and even update files via the web ui googlecode.com has so I want to make it easier to sync between repository and local.

Thanks for any advice

Edit: I can see that the changeset 176:e571b17295e9 is not important and I just want to merge it with the tip with no actual change but getting 1 head.

enter image description here

So I try and I get that the changeset is irrevelavant and I don't care about this change:

$ hg diff -c e571b17295e9
diff -r f50d4c4461e5 -r e571b17295e9 classifiedsmarket/app.yaml
--- a/classifiedsmarket/app.yaml    Thu Jan 06 11:36:10 2011 +0000
+++ b/classifiedsmarket/app.yaml    Sat Jan 08 04:45:07 2011 +0000
@@ -4,6 +4,10 @@
 api_version: 1
 default_expiration: "400d 5h"
 handlers:
+- url: /twitter
+  script: /twitter_oauth_handler.py
+- url: /oauth.*
+  script: /twitter_oauth_handler.py
 - url: /
   script: i18n.py
 - url: /li

So why do I need so much administation about changesets that do not matter at all?

So now I try this other way which also fails. Great. Choose mercurial and you won't be able to do development since all you do is try to lose some garbage:

hg update -r 123
hg commit --close-branch -m 'Closing old branch'
hg update -C default

My try:

$ hg update -r e571b17295e9
avbryter: crosses branches (merge branches or use --clean to discard changes)

Great, nothing works and what I'm trying to do is really simple. I try some more to really understand that it's impossible to do something really simple and how we lose time trying to do the most basic thing and how Mercurial can't do something simple:

$ hg head
ändring:     235:68bc6873fafb
märke:       tip
användare:   niklasro
datum:       Tue Sep 06 11:53:32 2011 +0000
kortfattat:  added fblist

ändring:     176:e571b17295e9
användare:   tekniklas
datum:       Sat Jan 08 04:45:07 2011 +0000
kortfattat:  twitter support added

ä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

$ hg merge -r e571b17295e9
avbryter: outstanding uncommitted changes (use 'hg status' to list changes)

So I try another way just to make clear how VCS completely stops me from being able to do development and these stupid revisions instead that won't work not even when it's really simple you're trying to do:

$ hg update -r e571b17295e9
avbryter: crosses branches (merge branches or use --clean to discard changes)

I ended creating a new local directory for each revision I wanted to close, cloned the revision, closed it, committed and pushed from the local clone and it seems to have worked but did I do this the right way? It seems I can still "open" the closed heads which is good but I didn't try yet to sync with other people's changes and I didn't try to do a change via the webui in googlecode.com and pull / merge with local clone.

So I closed uncommitted(?) changesets to mercurial by cloning 3 revisions and close them one by one instead of just hg head -r -close or some simple gear to hg that can handle uncommitted changesets.

It looks resolved now and I can view what the multiple heads were:

o  changeset:   181:bb0545ceff33
|  parent:      179:b03d10fc4260
|  user:        tekniklas
|  date:        Sun Jan 09 04:39:33 2011 +0000
|  summary:     twitter support
|
| o  changeset:   180:9bbefafbdb16
| |  parent:      178:e571b17295e9
| |  user:        niklasro
| |  date:        Tue Sep 06 14:09:19 2011 +0000
| |  summary:     close badbranch, this approach never worked
| |
o |  changeset:   179:b03d10fc4260
| |  parent:      177:f50d4c4461e5
| |  user:        tekniklas
| |  date:        Sun Jan 09 04:32:12 2011 +0000
| |  summary:     removed aeoid
| |
| o  changeset:   178:e571b17295e9
|/   user:        tekniklas
|    date:        Sat Jan 08 04:45:07 2011 +0000
|    summary:     twitter support added
|
o  changeset:   177:f50d4c4461e5
|  user:        tekniklas
|  date:        Thu Jan 06 11:36:10 2011 +0000
|  summary:     i18n reports

...

o  changeset:   163:aa078cbdbbe5
|  parent:      161:51ec76c45cf0
|  user:        tekniklas
|  date:        Sat Dec 18 19:20:25 2010 +0000
|  summary:     fb login
|
| o  changeset:   162:37951de836dc
| |  parent:      160:f8d974793b12
| |  user:        niklasro
| |  date:        Tue Sep 06 14:17:18 2011 +0000
| |  summary:     close badbranch, this approach never worked
| |
o |  changeset:   161:51ec76c45cf0
| |  parent:      159:652958f895e2
| |  user:        tekniklas
| |  date:        Sat Dec 18 19:19:41 2010 +0000
| |  summary:     fb login
| |
| o  changeset:   160:f8d974793b12
| |  parent:      158:ef1d955b9236
| |  user:        tekniklas
| |  date:        Sat Dec 18 17:05:45 2010 +0000
| |  summary:     remove
| |
o |  changeset:   159:652958f895e2
| |  parent:      157:9658adb05792
| |  user:        tekniklas
| |  date:        Sat Dec 18 19:19:17 2010 +0000
| |  summary:     fb login
| |
| o  changeset:   158:ef1d955b9236
|/   user:        tekniklas
|    date:        Sat Dec 18 17:05:00 2010 +0000
|    summary:     removed
|
o  changeset:   157:9658adb05792
|  user:        tekniklas
|  date:        Fri Dec 17 21:57:36 2010 +0000
|  summary:     tabs

...

o  changeset:   92:9e48ce2a444e
|  parent:      90:a381c59aedc1
|  user:        ubuntu@ubuntu
|  date:        Mon Aug 02 04:30:31 2010 +0000
|  summary:     coordinates
|
| o  changeset:   91:84facd40c690
| |  parent:      89:008a2ac46b4f
| |  user:        niklasro
| |  date:        Tue Sep 06 14:18:58 2011 +0000
| |  summary:     close badbranch, this approach never worked
| |
o |  changeset:   90:a381c59aedc1
| |  parent:      88:cfcd7313278d
| |  user:        ubuntu@ubuntu
| |  date:        Mon Aug 02 04:30:16 2010 +0000
| |  summary:     logo
| |
| o  changeset:   89:008a2ac46b4f
|/   user:        tekniklas
|    date:        Sun Aug 01 07:10:40 2010 +0000
|    summary:     classifiedsmarket/market/market_ad_preview.html
|
o  changeset:   88:cfcd7313278d
|  user:        ubuntu@ubuntu
|  date:        Sun Aug 01 05:58:50 2010 +0000
|  summary:     previewform

...

Upvotes: 4

Views: 3156

Answers (2)

Macke
Macke

Reputation: 25710

Take a look at the revision graph, and it shall be clearer to you:

This can be done via:

  • hg serve and open webbrowser to http://localhost:8000
  • hg glog if you've enabled the graph log extension (use -l 20 to se latest 20 commits only)
  • Use TortoiseHg, if available on your OS.

It will looks something like this:

 TortoiseHg revision log view

In order to combine the changes in these heads, you need to merge them. See 68040 above, which combines two heads into one. This is necessary if you have commits coming in from several locations simultaneously.

Upvotes: 2

Martin Geisler
Martin Geisler

Reputation: 73808

You can run

hg diff -c R

to see what you changed in changeset R. You can also use a log viewer like TortoiseHg se see that and to see where the changesets appear in the changeset graph.

The basic work cycle is

# work
hg commit
# work
hg commit
hg push
# aborts: multiple remote heads
hg pull
# hg heads show two heads
hg merge
hg commit
hg push

Upvotes: 2

Related Questions