I'm relatively new to Mercurial and my team is trying it out right now as a replacement for Subversion.
How can I commit and push a single file out to another repository while leaving other modifications in my working directory uncommitted (or at least not pushed to the other repository)?
This happens for us with database migrations. We want to commit the migration to source control so a DBA can view and edit it while we're working on the code modifications to go along with that database migration. The changes aren't yet ready to go so we don't want to push all of them out.
In subversion, I'd simply do:
svn add my_migration.sql
# commit only the migration, but not the other files I'm working on
svn commit -m "migration notes" my_mygration.sql
and continue working locally.
This doesn't work with mercurial as when I'm pushing it out to the other repository, if there are changes to it that I haven't pulled down, it wants me to pull them down, merge them, and commit that merge to the repository. Commits after a merge don't allow you to omit files so it forces you to commit everything in your local repository.
The easiest thing that I can figure out is to commit the file to my local repository, clone my local repository, fetch any new changes from the actual repository, merge them and commit that merge, and them push my changes out.
hg add my_migration.sql
hg commit -m "migration notes" my_migration.sql
cd ..
hg clone project project-clone
cd project-clone
hg fetch http://hg/project
hg push http://hg/project
This works, but it feels like I'm missing something easier, some way to tell mercurial to ignore the files already in my working directory, just do the merge and send the files along. I suspect mercurial queues can do this, but I don't fully grok mq yet.
Thanks to Josh Matthews below, the shelve command is exactly what I'm looking for. I didn't see any great install instructions with some googling, so here is the combined stuff I used to get it working:
Get it with:
hg clone http://freehg.org/u/tksoh/hgshelve/ hgshelve
The only file (currently) in the project is the hgshelve.py file.
Modify your ~/.hgrc to add the shelve extension, pointing to where you cloned the repo:
[extensions]
hgshelve=/Users/ted/Documents/workspace/hgshelve/hgshelve.py
Then you can hg shelve
and hg unshelve
to temporarily store changes away. It lets you work at the "patch hunk" level to pick and choose the items to shelve away. It didn't appear to shelve a file had listed for adding, only files already in the repo with modifications.