6

I cloned a Mercurial repo and made some changes in the checked out code. I then grabbed those changes (7 files) and committed them with hg commit but without having created a bookmark first.

This is the output of my hg summary command:

parent: 8172:b39efc1322fe tip
  Made some changes in my feature
branch: default
commit: 7 modified
update: 2 new changesets, 3 branch heads (merge)
phases: 3 draft

These changes won't be ready to be pushed for at least another week, so I want to switch to a new bookmark and work on other parts of the code.

The problem is that I realized that I had made a commit without being in a bookmark, so I'm afraid that after switching to a new bookmark my committed changes could be lost.

Is there an easy way to move these committed changes into a new bookmark?

Mike Laren
  • 8,028
  • 17
  • 51
  • 70

2 Answers2

7

There is no need to be afraid at all: mercurial won't forget anything you committed unless you explicitly do both: enable history editing extensions and willingly use them in a way that you actually remove one or more changesets.

Mercurial is not git and mercurial does never forget or garbage-collect a changeset when it is not currently checked out and has no name (bookmark) attached to it.

You can show you all your heads using hg heads. And you can always create new bookmarks, attached to an arbitrary changeset by hg bookmark --rev XXX MyBookmark where XXX is the changesetID to which you want to attach the bookmark.

planetmaker
  • 5,884
  • 3
  • 28
  • 37
-4

I'm afraid that after switching to a new bookmark my committed changes could be lost.

How can you imagine this? OMFG, you committed your changes to repository (your clone), you have this changeset (8172:b39efc1322fe) in it. When|if you'll svn up to another node, you'll just change parent of your Working Directory, on pull you'll get "2 new changeset" and, as result "3 branch heads" - 2 new changesets + your commit 8172, and this b39efc1322fe will be always one of heads, even you'll up and work in another.

If you are afraid to forget it (how??? really), you can post-fact bookmark this (committed) changeset with hg bookmark -r b39efc1322fe $WIP && hg commit -m "Bookmarked my work" in order to hg up $WIP when it will be time to continue this chunk of changes

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
  • 1
    No need to be snarky - it's a legitimate question to want to move the commit to a new bookmark, whether or not the fear is founded. – shiri Aug 27 '15 at 18:45