Mercurial > public > mercurial-scm > hg-stable
diff 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 |
line wrap: on
line diff
--- a/mercurial/localrepo.py Tue Nov 24 21:08:39 2009 -0500 +++ b/mercurial/localrepo.py Tue Nov 24 21:08:40 2009 -0500 @@ -825,6 +825,7 @@ extra, changes) if editor: cctx._text = editor(self, cctx, subs) + edited = (text != cctx._text) # commit subs if subs: @@ -844,7 +845,14 @@ msgfile.write(cctx._text.rstrip() + '\n') msgfile.close() - ret = self.commitctx(cctx, True) + try: + ret = self.commitctx(cctx, True) + except: + if edited: + msgfn = self.pathto(msgfile.name[len(self.root)+1:]) + self.ui.write( + _('note: commit message saved in %s\n') % msgfn) + raise # update dirstate and mergestate for f in changes[0] + changes[1]: