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.
- Call the current changeset "base".
- Commit all outstanding files and call that say "shelve" or
"partial" or something similar.
- Update to the previous version (ie "base").
- Revert all files to "shelve"
- 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.
- Commit these parts / hunks you want in the first
commit.
- Repeat steps 3, 4 & 5 until you have committed all the
differences between "base" and "shelve"
- Turn on history editing and strip the "shelve" commit.
Method 2 : Keep Diffs open.
- Be careful you could loose history if you do
this wrong. Backup your whole repository until you get the hang of
using this technique.
- Diff all the files in an external diff program like
FileMerge.
- 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.
- Commit the current files.
- Switch back to the FileMerge documents and choose the rest of
the hunks, and save.
- Commit the rest of the files.