How do I do hunk level commits?

A "hunk level commit" is the ability to select and commit only some of the outstanding changes to a file.

Currently, in MacHg there is no graphical support for hunk level commits. I definitely have this as a planned addition to MacHg though...

However, you can fake it a little in a couple of ways.

Method 1 : Branch and step back.

  1. Call the current changeset "base".
  2. Commit all outstanding files and call that say "shelve" or "partial" or something similar.
  3. Update to the previous version (ie "base").
  4. Revert all files to "shelve"
  5. Diff the files and choose only the hunks / parts you want in the first commit. Thus preparing all the files in the states you want for the first commit.
  6. Commit these parts / hunks you want in the first commit.
  7. Repeat steps 3, 4 & 5 until you have committed all the differences between "base" and "shelve"
  8. Turn on history editing and strip the "shelve" commit.

Method 2 : Keep Diffs open.

  1. Be careful you could loose history if you do this wrong. Backup your whole repository until you get the hang of using this technique.
  2. Diff all the files in an external diff program like FileMerge.
  3. In the open FileMerge program choose the hunks / states that you want the files to be in for the first commit and save the files. But don't close the FileMerge documents.
  4. Commit the current files.
  5. Switch back to the FileMerge documents and choose the rest of the hunks, and save.
  6. Commit the rest of the files.

Method 3 : Install the crecord extension and just use that from the command line.