Mercurial > hg
diff mercurial/localrepo.py @ 9934:720f70b720d3
commit: save commit message so it's not destroyed by rollback.
(issue1635)
Rationale: if a pretxncommit hook rejects this commit, the transaction
is rolled back and the user's commit message is irrevocably lost.
So save a copy in .hg/last-message.txt, just in case. Also handy if
the user deliberately rolls back a commit in order to amend it.
author | Greg Ward <greg-hg@gerg.ca> |
---|---|
date | Tue, 24 Nov 2009 21:08:39 -0500 |
parents | ea3acaae25bb |
children | 48b81d9bca8d |
line wrap: on
line diff
--- a/mercurial/localrepo.py Fri Aug 14 08:19:49 2009 -0400 +++ b/mercurial/localrepo.py Tue Nov 24 21:08:39 2009 -0500 @@ -835,6 +835,15 @@ state[s] = (state[s][0], sr) subrepo.writestate(self, state) + # Save commit message in case this transaction gets rolled back + # (e.g. by a pretxncommit hook). (Save in text mode in case a + # Windows user wants to edit it with Notepad. Normalize + # trailing whitespace so the file always looks the same -- + # makes testing easier.) + msgfile = self.opener('last-message.txt', 'w') + msgfile.write(cctx._text.rstrip() + '\n') + msgfile.close() + ret = self.commitctx(cctx, True) # update dirstate and mergestate