comparison mercurial/localrepo.py @ 9935:48b81d9bca8d

commit: if relevant, tell user their commit message was saved. (issue1635) Specifically, if: 1) the user edited the message (it didn't come straight from -m) and 2) the commit was aborted by an exception then the saved commit message in .hg/last-message.txt could come in handy, so mention it with a ui.write(). This doesn't help users who manually rollback to amend a changeset: the fact that the message was saved to .hg/last-message.txt is invisible in that case.
author Greg Ward <greg-hg@gerg.ca>
date Tue, 24 Nov 2009 21:08:40 -0500
parents 720f70b720d3
children bc3f762af82e
comparison
equal deleted inserted replaced
9934:720f70b720d3 9935:48b81d9bca8d
823 823
824 cctx = context.workingctx(self, (p1, p2), text, user, date, 824 cctx = context.workingctx(self, (p1, p2), text, user, date,
825 extra, changes) 825 extra, changes)
826 if editor: 826 if editor:
827 cctx._text = editor(self, cctx, subs) 827 cctx._text = editor(self, cctx, subs)
828 edited = (text != cctx._text)
828 829
829 # commit subs 830 # commit subs
830 if subs: 831 if subs:
831 state = wctx.substate.copy() 832 state = wctx.substate.copy()
832 for s in subs: 833 for s in subs:
842 # makes testing easier.) 843 # makes testing easier.)
843 msgfile = self.opener('last-message.txt', 'w') 844 msgfile = self.opener('last-message.txt', 'w')
844 msgfile.write(cctx._text.rstrip() + '\n') 845 msgfile.write(cctx._text.rstrip() + '\n')
845 msgfile.close() 846 msgfile.close()
846 847
847 ret = self.commitctx(cctx, True) 848 try:
849 ret = self.commitctx(cctx, True)
850 except:
851 if edited:
852 msgfn = self.pathto(msgfile.name[len(self.root)+1:])
853 self.ui.write(
854 _('note: commit message saved in %s\n') % msgfn)
855 raise
848 856
849 # update dirstate and mergestate 857 # update dirstate and mergestate
850 for f in changes[0] + changes[1]: 858 for f in changes[0] + changes[1]:
851 self.dirstate.normal(f) 859 self.dirstate.normal(f)
852 for f in changes[2]: 860 for f in changes[2]: