Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's the easiest way to commit and push a single file while leaving other modifications alone?
    primarykey
    data
    text
    <p>I'm relatively new to Mercurial and my team is trying it out right now as a replacement for Subversion. </p> <p>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)?</p> <p>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.</p> <p>In subversion, I'd simply do:</p> <pre><code>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 </code></pre> <p>and continue working locally.</p> <p>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.</p> <p>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.</p> <pre><code>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 </code></pre> <p>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.</p> <p>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:</p> <p>Get it with:</p> <pre><code>hg clone http://freehg.org/u/tksoh/hgshelve/ hgshelve </code></pre> <p>The only file (currently) in the project is the hgshelve.py file.</p> <p>Modify your ~/.hgrc to add the shelve extension, pointing to where you cloned the repo:</p> <pre><code>[extensions] hgshelve=/Users/ted/Documents/workspace/hgshelve/hgshelve.py </code></pre> <p>Then you can <code>hg shelve</code> and <code>hg unshelve</code> 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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload