Search code examples
version-controlmercurialtortoisehg

Shelving or otherwise preserving changes in mercurial


Please, help me understand Hg mercurial with tortoise Hg. I am working on a longer task on my local repo, having a lot of changes.
I am not ready to commit it, but central repo already has a lot of other people' changes which I need to get. When I do pull, I can see that my changes are on a branch lined from revision 25, but the public / central repository are already on 27.
I want to get everything that is on 27 and at the same time keep everything I am working on. When I do "Merge" tortoise tell me to

  • shelve
  • discard
  • commit my changes

I need to do shelve, but do not grasp what it is.
How will I bring them back afterwards? For now - there are no conflicts. My files are separate. Of course, I understand that I can manually back them up somewhere, merge the branches and then places them back. But there are a log of them to do one by one, and also my organization discourages such behavior.


Solution

  • I think to large extent you are confused over terminology. Maybe also about how Mercurial functions.

    "Commit" - records your changes in source control. Does not affect other users.

    "Shelve" - records any changes in your working directories to a temporary location, removing said changes from your working directory.

    You should be committing frequently, as a general rule. Commit whenever you have work that should be preserved which is completed to your satisfaction. Its like a form of backup.

    The message about merging is because you have UNcommitted changes in your working directory. It doesn't want to disturb them without getting your input - which is why it offers to "commit, shelve, or discard". You should instead commit what you need first, and then merge.

    Finally once you have merged you will need to "push" changes before anyone else will be able to see them.


    This is not meant as a criticism, but you are having difficulties with the basic features of Mercurial (or any other source control system many of which operate similarly). You should look for a tutorial and practice in a test repository where no harm will come to any real work. Also HG has pretty good documentation.