I don't believe uncommitted changes are intrinsically a bad thing. You refer to an "inability to merge with them" - if you have an uncommitted change to some file, and you pull and update a change to that file, Mercurial will start the merge process just as if you had committed it, then asked for a merge. Did you mean something different?
So, for local changes that you don't yet want to share with other developers, you have two approaches. The first is to keep the changes in your working copy, but not push them, and the other is to put them aside, out of the working copy. Which you choose depends on whether you want to have these changes available as you work.
If you keep them in the working copy, incoming changes will work fine, so you just need to avoid creating outgoing changes, and that means avoiding committing them. If the files are new, that's easy - just don't hg add
them. If they are already tracked, then you can specifically exclude them from commits with hg commit --exclude foo.txt
. If you have a large number of files to exclude, or will be excluding them from many commits (eg for a permanent change to a local configuration file), look at the exclude extension.
If you are prepared to move the changes aside, you have another set of options. The simplest thing is simply to use hg diff
on the files to produce a patch describing them, which you keep somewhere safe, then hg patch --no-commit
to reapply that patch when you want the changes back. You can make this smoother by installing the shelve extension, the attic extension, or some other relative. You could also use the queues extension, but that's using a sledgehammer to crack a nut. You could even just commit the changes, then update back to the parent and commit other work there, leaving the changes in a stubby anonymous branch - hg commit -m 'temporary branch' && hg up $(hg log -r 'parents(.)' --template '{node}')
(although it may be easier to do manually!). You would then have to take care not to push that changeset, though.