Search code examples
mercurialbranchbookmarks

Mercurial - Merge with non-head revision


I was working on a project and when I was ready for a 0.1.0 release I created a bookmark called release, tagged that revision as 0.1.0, and then made the bookmark inactive and continued working on my project.

The revisions look something like this (from newest to oldest):

  • Tip (hg update default goes here)
  • Some more revisions
  • Revision with bookmark (hg update release goes here)
  • Some more revisions

My intention was to do hg update release followed by hg merge default and hg tag <version> whenever a new version was ready. However, that produces the following error:

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

I obviously only have one head and I'm not sure what hg update would do. hg update release when I am at the tip does update to the proper revision. Is there a way, given my current scenario and still using bookmarks (no named branched), to merge the revision pointed to by release with the tip (thereby creating a new head)? My initial thought is to make a small change to release, commit it in order to create a new head, and then merge; however, I would rather be sure of what I am doing before I try that.


Solution

  • Merging is only needed when you have multiple heads, i.e., non-linear history.

    However, I'm not really sure if your workflow is more complicated than it should. Keep in mind that you are not forced to update to a particular revision in order to tag it. See the help for the tag command.