I would suggest saving this message in a variable. In aurum (plugin for VCS↔Vim integration) there is the following logic coded: when buffer with commit message is wiped out or written (which triggers actual committing and wiping it out) I save three variables:
- Commit message.
- Current commit hex (you can see it using
hg log -r .
). - Current repository root.
. Then when committing something again the following logic is used: if current repository root is the same as the saved one and so is current commit hex then commit message is taken from the variable and initializes the buffer.
Reasons for the following behavior:
- If commit failed I want to restore commit message (same as yours).
- If I did
hg rollback
, edited something and want to commit again I want to restore commit message. - If I closed commit buffer because I remembered I want to code some more changes I want to …
- If I did not do anything of the above I do not want to see old commit message.
Saving current commit hex is here for distinguishing between first three and the last case.