comparison 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
comparison
equal deleted inserted replaced
9933:2e7902158af9 9934:720f70b720d3
832 for s in subs: 832 for s in subs:
833 self.ui.status(_('committing subrepository %s\n') % s) 833 self.ui.status(_('committing subrepository %s\n') % s)
834 sr = wctx.sub(s).commit(cctx._text, user, date) 834 sr = wctx.sub(s).commit(cctx._text, user, date)
835 state[s] = (state[s][0], sr) 835 state[s] = (state[s][0], sr)
836 subrepo.writestate(self, state) 836 subrepo.writestate(self, state)
837
838 # Save commit message in case this transaction gets rolled back
839 # (e.g. by a pretxncommit hook). (Save in text mode in case a
840 # Windows user wants to edit it with Notepad. Normalize
841 # trailing whitespace so the file always looks the same --
842 # makes testing easier.)
843 msgfile = self.opener('last-message.txt', 'w')
844 msgfile.write(cctx._text.rstrip() + '\n')
845 msgfile.close()
837 846
838 ret = self.commitctx(cctx, True) 847 ret = self.commitctx(cctx, True)
839 848
840 # update dirstate and mergestate 849 # update dirstate and mergestate
841 for f in changes[0] + changes[1]: 850 for f in changes[0] + changes[1]: