views:

70

answers:

1

The scenario is that I arrive at work one morning and pull, update, merge my mercurial tree. From the now latest revision I begin working on todays task. I reach a logical milestone and does a commit. The tree now looks like this:

*  <- my first commit for the day
|
*  <- merge commit from shared repos by team

Now the boss comes along, something horrible has happened and it needs my immediate attention. He wants the solution pushed asap.

My plan for the day is disrupted. What is the best way to use mercurial to tackle this problem?

  • I could just write the solution and make another commit followed by a push. But this is bad since that commit would have my own first commit as parent, thus pushing incomplete code.
  • In a perfect world maybe that new feature Im coding will be in its own branch. But its a small feature and Im lazy, so it currently resides in default. I could try to find a way to move a commit from one branch to another.
  • I could ignore the panicking boss, do two or three more commits to complete the feature, push that and then start working on the fix, bringing those in as a separate commit and push.

Neither of those feels good. I would like something along the lines of:

  1. Do an update, bringing me back to the merge commit.
  2. Do the fix and commit it.
  3. Push only the fix commit, leaving the incomplete-feature commit still unpushed.

Thus making the history like this:

*  <- fix commit (pushed)
|
| *  <- my first commit for the day (unpushed)
|/
*  <- merge commit from shared repos by team

We've just migrated to mercurial here at the office, and this is one problem I would like to tackle. Any mercurial gurus here that mind sharing some wisdom?

+2  A: 

The workflow you're describing looks good (update to merge, commit, push -r the fix). If you feel not comfortable with anonymous branches, you can first clone -r the repo up to the merge, commit and push.

tonfa
You mean I can use the -r flag to specify a specific revision (the fix revision/commit) and that, and only that, revision will be commited?
mizipzor
more precisely it will push all revisions up to that revision, so following your example, the merge and fix revisions will get pushed.
Idan K
Exactly what I was looking for, and so simple. Thanks a bunch! =)
mizipzor