mercurialshelving

Mercurial: How can a I make a snapshot of my working directory without doing a changeset?


While working on a new feature I arrive at a point where it roughly works, but is still not at a point where I want to create a changeset. I would however create a "restore point" or a "snapsnot" so I can come back to this roughly working version of my codebase. In TFS I would create a shelve set.

In mercurial, shelve sets behave different: As soon as I move a file into a shelf, the file reverts to the state of the last changeset. So for my purpose of creating a snapshot and continue working, this behavior makes shelving not a solution.

How can I snapshot my work and continue with the files as they are?

I know there are many questions about shelving in mercurial here, but I could not find an answer to this question in them.

Comment on the helpful answers by @Mathiasdm and @Gill Bates

For now I go with commit --amend, which is also available in TortoisHG: the commit button can be converted to an amend button.

Ammend adds the changes to the previous commit instead of creating a new changeset. So

"hg shelve && hg unshelve --keep" and the mq extension are nice alternatives.


Solution

  • One command that is particularly suited for this is:

    hg commit --amend
    

    It allows you to create a commit and keep improving it (amending it). Every time you do 'hg commit --amend', all additional changes in the working directory are added to it.

    I know this does not sound 'shelve-like', but it sounds like what you need is actually not really a shelve.