3
votes

I've been trying to do more branching in Mercurial and decided to use bookmarks to do it. This particular repo pushes not only to a mercurial repo, but also to a git repo via hg-git.

I'm using track.current in my bookmarks configuration. Anyway, so I created a bookmark and did some commits

hg bookmark feature
hg update feature
hg commit ... 

and then I went to merge my feature branch back into my master branch

hg update master
hg merge feature

However, at this point I get:

abort: nothing to merge
(use 'hg update' or check 'hg heads')

Looking at hg bookmarks reveals that master and feature are indeed pointing to different revisions.

I don't understand why I'm getting this message. I also made the mistake of pushing on anyway. I didn't push the bookmark with it, so my Mercurial repo looks fine. However, hg-git picked up on the usage and made a branch in my git repo. So, now I have this very weird inconsistent source tree between the two repos. How do I fix that and how can I properly do this in the future?

2
Heh, tried doing a force to update master and now hg-git freezes on push. Not sure if it's a bug there or if that's not the right thing to doEarlz
I don't know anything about hg-git, but did you run hg heads when it said there was nothing to merge? Master and feature could be pointing to different revisions, but if you didn't make any commits to master, there won't be anything to merge together. You basically just labeled two revisions, in that case.JeffB
@JeffB You should write an answer for that. The hg-git freeze sounds like a bug to me, but I think you've hit the nail on the head for the merging problem. Mercurial doesn't have Git's concept of "fast-forward" merges; if master is an ancestor of feature, then merge will fail and the right thing to do is just move master to point to feature. Unfortunately, this behaviour is a little inconsistent: if master is an ancestor of feature, but they're on different named branches, merge will succeed. It would be handy to be able to force a merge changeset for revisions on the same branch.anton.burger
@shambulator Done, but I found a better explanation in another question, so I linked to that. I'm not sure if that actually warrants an answer or just a comment here.JeffB

2 Answers

2
votes

Creating a bookmark in Mercurial doesn't actually create a new head (or branch, in other words), it labels a revision (and then will auto-update when you make commits while it's active). You don't actually get a new head (and therefore need to merge) until you make commits to two bookmarks. This might be helpful to read. Also, this answer has a good explanation.

1
votes

In this case it looks like your feature bookmark is a direct descendent of master. Mercurial doesn't do git-style fast-forward merges, so you just 'fake it'. Instead of:

hg update master
hg merge feature

You can just:

# We still have the feature bookmark checked out
hg bookmark --delete feature
hg bookmark --force master