# HG changeset patch # User Renato Cunha # Date 1281987320 10800 # Node ID 59ec12093261fe012bae847fae05918e7a98d001 # Parent 851161f070689a392431c68df6615ab5c3264490 mq: save qrefresh message for easy recovery in case it fails (issue2062) Currently, if you start editing a commit message from qrefresh -e and, for any reason: forget you were editing it, leave the editor open and start qpopping and qpushing, when you decide to save your commit message, it is going to fail. This patch copies the commit behavior of saving the message contents in $HGROOT/.hg/last-message.txt before continuing. diff -r 851161f07068 -r 59ec12093261 hgext/mq.py --- a/hgext/mq.py Tue Aug 17 17:38:19 2010 -0500 +++ b/hgext/mq.py Mon Aug 16 16:35:20 2010 -0300 @@ -2041,6 +2041,10 @@ If -s/--short is specified, files currently included in the patch will be refreshed just like matched files and remain in the patch. + If -e/--edit is specified, Mercurial will start your configured editor for + you to enter a message. In case qrefresh fails, you will find a backup of + your message in ``.hg/last-message.txt``. + hg add/remove/copy/rename work as usual, though you might want to use git-style patches (-g/--git or [diff] git=1) to track copies and renames. See the diffs help topic for more information on the @@ -2057,6 +2061,10 @@ patch = q.applied[-1].name ph = patchheader(q.join(patch), q.plainmode) message = ui.edit('\n'.join(ph.message), ph.user or ui.username()) + # We don't want to lose the patch message if qrefresh fails (issue2062) + msgfile = repo.opener('last-message.txt', 'wb') + msgfile.write(message) + msgfile.close() setupheaderopts(ui, opts) ret = q.refresh(repo, pats, msg=message, **opts) q.save_dirty()